New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR-11364] enum formatter with optionSet doesn't show the right value #4559
Comments
Looks like the runtime gets this right if you call |
I'll look in an hour or such. |
@adrian-prantl friss (JIRA User) and I discussed this in the past several times. Unfortunately modifying values for swift types is something that didn't really get a lot of attention, so if it works, it's not really by design. We're receiving more reports about this, so we might reconsider whether we want to spend some time to modify the compiler (and lldb) to do the right thing, but I'm afraid there's nothing planned yet. |
We could prevent reassignment to happen in swift [and just emit an error], as they only work in few cases today. Investigating how to fix the problem in the compiler is a major undertaking and probably involves many changes to code generation (IRGen et similia). |
Wait, what do you mean by "modifying values for swift types"? This is a plain old var getting a new value; it's not shadowing an existing value. |
I need more coffee, sorry. Let me look at this again. I changed the enum code so there are chances this got fixed in 5.1, but I need to double check. |
Yes, this is fixed in ToT. Please re-try with a nightly snapshot. It was a bug in computing the enum layout. 1> struct OptSet: OptionSet {
2. public typealias RawValue = UInt32
3.
4. var rawValue: UInt32
5.
6. static let v1 = OptSet(rawValue: 1)
7. static let v2 = OptSet(rawValue:2)
8. }
9.
10. enum Test {
11. case t1
12. case t2(OptSet)
13. case t3
14. }
15.
16. var t: Test = .t1
t: Test = t1
17> t = .t3
18> t
$R0: Test = t3 |
Environment
version 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.4) on macOS
Additional Detail from JIRA
md5: 50ebfd3bc8a3f60125a929a6d24339aa
Issue Description:
When creating an enum with an optionSet associated value, changes on the enum variable are not reflected to the varaiable.
When changing the value to `t3` the value remains at `t1`
The value will still be `t1`.
It's not the case if the associated value doesn't extend the `OptionSet`.
The text was updated successfully, but these errors were encountered: