Skip to content
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-11062] Compiler crashes when using attribute syntax with a property wrapper #53454

Closed
swift-ci opened this issue Jul 3, 2019 · 7 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software property wrappers Feature: property wrappers

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jul 3, 2019

Previous ID SR-11062
Radar rdar://problem/54141935
Original Reporter Anandabits (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

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

md5: a7075c0aeed423d5e44fdf989d81249c

is duplicated by:

  • SR-11441 Compiler crash on Property Wrapper
  • SR-11448 Abort trap: 6 when initialising Property Wrapper with variadic argument AND supplying initial value for wrappedValue.
  • SR-11480 PropertyWrappers: Compiler crashes (trap 6) when used with initial value + default param

Issue Description:

The attached project crashes in Xcode 11 beta 3 when using attribute syntax for the property wrappers. When the wrapper type is used as the type of the property (abandoning the property wrapper sugar) the code works fine after adding `.wrappedValue` where necessary. The same issue occurs in Xcode 11 beta 2, although an older version of the code is required.

@belkadan
Copy link
Contributor

belkadan commented Jul 6, 2019

@swift-ci create

@DougGregor
Copy link
Member

Ah, this is fixed by #26012 The code builds properly with master + that fix

@AnnaZaks
Copy link
Mannequin

AnnaZaks mannequin commented Aug 9, 2019

Anandabits (JIRA User), Could you verify if the problem is fixed and if so move the JIRA to "Closed"?

Thanks!
Anna

@swift-ci
Copy link
Collaborator Author

swift-ci commented Aug 9, 2019

Comment by Matthew Johnson (JIRA)

I can confirm that this is fixed when I provide the initial value in the attribute initializer as follows:

@Inspectable(initialValue: 0, label: Text("duration"), control: { Slider(value: $0, in: 1...10, label: { Text("duration") }) })
var test: CGFloat

But the compiler still crashes when attempting to use direct initialization in Xcode 11 beta 5:

@Inspectable(label: Text("duration"), control: { Slider(value: $0, in: 1...10, label: { Text("duration") }) })
var test: CGFloat = 0 [^Archive.zip] 

I'm attaching a new sample project demonstrating the new crasher. See ImagePulse.swift.

@DougGregor
Copy link
Member

Managed to reduce this a bit:

struct MyText<V> {
  let label: String
  let value: V
}
extension MyText where V == Void {
  init(_ label: String, defaulted: Int = 17) {
    self.label = label
    self.value = ()
  }
}
struct ImagePulse {
  @Inspectable(control: { MyText("duration") })
  var test: Double = 0
}
@propertyWrapper
final class Inspectable<Value> {
  var wrappedValue: Value
  
  init<V>(wrappedValue initialValue: Value, control: @escaping () -> V) {
    self.wrappedValue = initialValue
  }
} 

@DougGregor
Copy link
Member

https://github.com/DougGregor/swift/pull/new/sr-11062

@DougGregor
Copy link
Member

Fixed!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software property wrappers Feature: property wrappers
Projects
None yet
Development

No branches or pull requests

4 participants