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-6744] Compiler crash when using KeyPath to property with the same name as a func #49293

Closed
ffried opened this issue Jan 12, 2018 · 4 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 4.1

Comments

@ffried
Copy link
Contributor

ffried commented Jan 12, 2018

Previous ID SR-6744
Radar None
Original Reporter @ffried
Type Bug
Status Closed
Resolution Done

Attachment: Download

Environment
Apple Swift version 4.1-dev (LLVM b623e863a9, Clang 27a368e018, Swift edecd95413) Target: x86_64-apple-darwin17.3.0
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 4.1Regression
Assignee @gregomni
Priority Medium

md5: b3976cc4019f8f9dab5185c5d91798d0

Issue Description:

The following code reliably crashes the compiler:

struct ABC {
let value: Int
func value(adding i: Int) -> Int { return value + i }
}

let abc = ABC(value: 0)
func get<T>(for kp: KeyPath<ABC, T>) -> T {
return abc[keyPath: kp]
}
_ = get(for: \.value)

The problem seems to be, that the property value has the same name as the value(adding:) function. It no longer crashes when the function is renamed (e.g. increasedValue(adding:)) or removed.

This works fine with Swift 4.0.

@moiseev
Copy link
Mannequin

moiseev mannequin commented Jan 12, 2018

/cc @jckarter

@gregomni
Copy link
Collaborator

#13943

@ffried
Copy link
Contributor Author

ffried commented Jan 16, 2018

Will this be fixed for Swift 4.1 as well?

@ffried
Copy link
Contributor Author

ffried commented Jan 16, 2018

Thanks for the quick fix btw!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 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 regression swift 4.1
Projects
None yet
Development

No branches or pull requests

3 participants