Skip to content

No fix-it for integer literal to OptionSet conversion #81305

Open
@AnthonyLatsis

Description

@AnthonyLatsis

Description

We introduced a fix-it to replace 0 with [] in the below example in #13899 and lost it at some point, probably because the only remaining test has been XFAILed for a very long time.

Reproduction

struct MyMask : OptionSet {
  init(_ rawValue: UInt) {}
  init(rawValue: UInt) {}
  init(nilLiteral: ()) {}

  var rawValue: UInt { return 0 }

  static var allZeros: MyMask { return MyMask(0) }
  static var Bingo: MyMask { return MyMask(1) }
}

let _: MyMask = 0

Expected behavior

Fix-it:

-let _: MyMask = 0
+let _: MyMask = []

Environment

Swift version 6.2-dev (LLVM 736ebbfa5fe3371, Swift d033eec)

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    OptionSetArea → standard library: The `OptionSet` protocolbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationexpressionsFeature: expressionsfix-itsFeature: diagnostic fix-itsinteger literalsFeature → literals: Integer literalsliteralsFeature → expressions: Literals such as an integer or string literalswift 6.2type checkerArea → compiler: Semantic analysis

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions