Enum didSet compiler crash

For the past weeks or maybe a month or so, the trunk development swift toolchains have been crashing with following code:

enum Foo {
  case a
  case b
  case c
}

var foo: Foo = .b {
  didSet {
    // stuff...
  }
}

Is there a way to workaround this bug? The code does not crash, if the variable is placed inside something, e.g. a struct.

1 Like

Ok, so one workaround is wrapping in struct:

struct Global {
    static var foo: Foo = .b {
        didSet {
            // stuff...
        }
    }
}

Can you file a bug and include your test case at bugs.swift.org?

Sure. https://bugs.swift.org/browse/SR-9485

1 Like
Terms of Service

Privacy Policy

Cookie Policy