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-6992] Implicit unwrapped Keypath #49540

Closed
swift-ci opened this issue Feb 13, 2018 · 4 comments
Closed

[SR-6992] Implicit unwrapped Keypath #49540

swift-ci opened this issue Feb 13, 2018 · 4 comments
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

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-6992
Radar None
Original Reporter poissonballon (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Apple Swift version 4.0.3 (swiftlang-900.0.74.1 clang-900.0.39.2)
Target: x86_64-apple-macosx10.9

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

md5: b778052f99be990ca14e5f1723237df7

Issue Description:

Hi,

When we create an implicitly unwrapped `ReferenceWritableKeyPath` we have a segmentation fault error.

var keypathNotForced: ReferenceWritableKeyPath<Pokemon, String?> = \Pokemon.trainerName
var keypathForced:    ReferenceWritableKeyPath<Pokemon, String?>! = \Pokemon.trainerName

pikachu[keyPath: keypathNotForced]  = "Sacha" // Doesn't generate compiler Error
pikachu[keyPath: keypathForced]     = "Sacha" // Generate Builtime compiler segmentation fault error

I don't know if it's related to this bug? https://bugs.swift.org/browse/SR-5551?jql=text%20\~%20%22keypath%22

I write a little sample here for helping: https://gist.github.com/PoissonBallon/48d9faa3d65ebdf61e2be90b792b9448

@belkadan
Copy link
Contributor

Looks like it's fixed in master. @jckarter, do you know whether the fix would have made it into 4.1?

@jckarter
Copy link
Member

It may have been incidentally fixed by the final death of IUO in master. I didn't do anything to make this work in 4.1.

@swift-ci
Copy link
Collaborator Author

Comment by Allan Vialatte (JIRA)

Oh nice 👍

Thank you for all your work!

But just FMI what you mean by "the final death of IUO" it sounds funny. 😃

@belkadan
Copy link
Contributor

Ah, well then this is probably still not going to work in 4.1, but it's probably too risky to try to fix just this issue at this point. As a workaround you can explicitly write ! when using keypathForced.

@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
Projects
None yet
Development

No branches or pull requests

4 participants