Variable expected when accessing static var

(wdb) #1

IDE: Fire
Version: Version 10.0.0.2400 (develop) built on talax, 20190503-102703. Commit dc2f219.
Target (If relevant): iOS
Description:
I am trying to store the current selected Client using a static var on the model class like Client.current = client but when I am compiling I am getting an error: Variable expected on that line. I am not sure why?

Total code:

        let client = Client(id: "1", name: "Client")
        Client.current = client

Expected Behavior:
Able to compile the project without compiler errors

Actual Behavior:
I am getting a compiler error when trying to compile the code

Steps:
Please a find reproducible project attached

BugReport6.zip (119.3 KB)

(marc hoffman) #2

What is Client, a struct? of so, stardust declared with let are read-only; you need to declare them with var for them to be mutable.

(wdb) #3

It’s defined as listed below as you can see the current-property is a var already. I don’t think that my client-variable which has an instance of Client-struct is a let should be an issue here.

final public struct Client {
    let id: String
    let name: String

    init(id: String, name: String) {
        self.id = id
        self.name = name

    }
}

extension Client {
    static var current: Client!
}
(marc hoffman) #4

ah, no. indeed. it, that should work.

(RemObjects) #5

Thanks, logged as bugs://82524

1 Like
(RemObjects) #6

bugs://82524 got closed with status fixed.

1 Like