Skip to content

Inout property wrapper function parameter crash #64261

Open
@stephencelis

Description

@stephencelis

Description

While SE-0293 Extend Property Wrappers to Function and Closure Parameters notes that inout support is a future direction, it causes a compiler crash today.

Steps to reproduce

Try to compile the following:

@propertyWrapper
struct Wrapper<Value> {
  var wrappedValue: Value

  var projectedValue: Self {
    get { self }
    set { self = newValue }
    _modify { yield &self }
  }

  init(wrappedValue: Value) {
    self.wrappedValue = wrappedValue
  }

  init(projectedValue: Self) {
    self = projectedValue
  }
}

func f<Value>(_ value: Value, _ operation: (inout Wrapper<Value>) -> Void) {
  var wrapper = Wrapper(wrappedValue: value)
  operation(&wrapper)
}

func g() {
  f(42) { $x in
    print($x)
  }
}

Expected behavior

I expect a compile error, not a crash (or better yet, support).

Environment

  • Swift 5.7, 5.8, and the March 2 development snapshot
  • Xcode 14.2+

Metadata

Metadata

Assignees

No one assigned

    Labels

    assertion failureBug → crash: An assertion failurebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareinoutFeature → types: `inout` typesproperty wrappersFeature: property wrappersswift 5.9type checkerArea → compiler: Semantic analysistypesFeature: typesverifier

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions