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-11637] Property wrapper crash when wrappedValue getter is mutating and setter is nonmutating #54048

Closed
theblixguy opened this issue Oct 19, 2019 · 4 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 regression SILGen Area → compiler: The SIL generation stage swift 5.2

Comments

@theblixguy
Copy link
Collaborator

Previous ID SR-11637
Radar rdar://problem/56467140
Original Reporter @theblixguy
Type Bug
Status Closed
Resolution Done
Environment

Swift version 5.1.1-dev (LLVM 6e04008c7f, Swift 2a2b600)
Target: x86_64-apple-darwin19.0.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 5.2Regression, CompilerCrash, PropertyWrappers, SILGen
Assignee @theblixguy
Priority Medium

md5: feb13e7ec6fc5d5a692e0f9014320c80

Issue Description:

@propertyWrapper
struct MutatingGetNonMutatingSetWrapper<T> {
  private var fixed: T
  
  var wrappedValue: T {
    mutating get { fixed }
    nonmutating set { }
  }
  
  init(wrappedValue initialValue: T) {
    fixed = initialValue
  }
}

struct Foo {
  @MutatingGetNonMutatingSetWrapper var text: String
}
Assertion failed: (address.isLValue() && "physical lvalue decl ref must evaluate to an address"), function emitUsingStorage, file /Users/suyashsrijan/Documents/swift-src/swift/lib/SILGen/SILGenLValue.cpp, line 2639.

On Swift 5.1 (release), this is diagnosed with an error: cannot assign to property: 'self' is immutable (although the error doesn't point to a valid source location).

@belkadan
Copy link
Contributor

@swift-ci create

@roop
Copy link
Mannequin

roop mannequin commented Jan 8, 2020

Opened PR #29069.

@hborla
Copy link
Member

hborla commented Jul 2, 2020

This is fixed in Swift 5.3 - could you please verify using Xcode 12 beta 1? Thank you!

@theblixguy
Copy link
Collaborator Author

I have confirmed this works on Xcode 12 beta 1 and no longer crashes. Thanks @roop and @hborla!

@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 regression SILGen Area → compiler: The SIL generation stage swift 5.2
Projects
None yet
Development

No branches or pull requests

4 participants