Uploaded image for project: 'Swift'
  1. Swift
  2. SR-11364

enum formatter with optionSet doesn't show the right value

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Done
    • Component/s: Compiler, LLDB for Swift
    • Labels:
    • Environment:

      version 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.4) on macOS

      Description

      When creating an enum with an optionSet associated value, changes on the enum variable are not reflected to the varaiable.

      struct OptSet: OptionSet {
          public typealias RawValue = UInt32
          
          var rawValue: UInt32
          
          static let v1 = OptSet(rawValue: 1)
          static let v2 = OptSet(rawValue:2)
      }
      
      enum Test {
          case t1
          case t2(OptSet)
          case t3
      }
      
      var t: Test = .t1
      

       

      When changing the value to `t3` the value remains at `t1`

      > t = .t3
      > t
      $R2: Test = t1
      

       

      The value will still be `t1`.

       

      It's not the case if the associated value doesn't extend the `OptionSet`.

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            fstaine Staine Florian
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: