Skip to content

[SR-10929] Property wrapper segmentation fault #53320

@stephencelis

Description

@stephencelis
Previous ID SR-10929
Radar rdar://problem/51809986
Original Reporter @stephencelis
Type Bug
Status Resolved
Resolution Done
Environment

Xcode 11 (beta 1)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, PropertyWrappers
Assignee None
Priority Medium

md5: 3d06fbaf3e18ebe3c1efa989fee0f169

Issue Description:

  1. Create Xcode 11 single view app project with SwiftUI.

  2. Replace ContentView with the following:

import SwiftUI

@propertyWrapper public final class Store<Value, Action>: DynamicViewProperty, BindingConvertible {

  public let update: (inout Value, Action) -> Void
  public private(set) var value: Value

  public var binding: Binding<Value> {
    Binding<Value>(
      getValue: { self.value },
      setValue: { self.value = $0 }
    )
  }

  public init(_ initialValue: Value, _ update: @escaping (inout Value, Action) -> Void) {
    self.update = update
    self.value = initialValue
  }
}

enum Action {
  case increment
  case decrement
}

func update(_ state: inout Int, _ action: Action) {
  switch action {
  case .increment:
    state += 1
  case .decrement:
    state -= 1
  }
}

struct ContentView : View {
  @Store(0, update) var store

  var body: some View {
    Text("Hello World")
  }
}

#if DEBUG
struct ContentView_Previews : PreviewProvider {
  static var previews: some View {
    ContentView()
  }
}
#endif 

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareproperty wrappersFeature: property wrappers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions