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-10826] can we make this keyPath subscript error message better? #53216

Open
tayloraswift opened this issue Jun 4, 2019 · 3 comments
Open
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation key paths Feature: key paths (both native and Objective-C) type checker Area → compiler: Semantic analysis

Comments

@tayloraswift
Copy link
Contributor

Previous ID SR-10826
Radar None
Original Reporter @Kelvin13
Type Bug
Status In Progress
Resolution
Environment

$ swift --version
Swift version 5.1-dev (LLVM e56fafcd29, Swift 938cb0f75e)
Target: x86_64-unknown-linux-gnu

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, KeyPaths, TypeChecker
Assignee @Kelvin13
Priority Medium

md5: 9f46781f4c455df10e5fefd87679e22b

relates to:

  • SR-5584 KeyPath error: type 'R' has no subscript members
  • SR-9217 Incorrect error message when the result of a keypath doesn't match the return type of a function

Issue Description:

:154:40: error: value of type 'Model' has no subscripts
let value:(Float, Float, Float) = model[keyPath: keyPath]

the problem here is that keyPath is a PartialKeyPath, and value needs to be declared as Any, instead of a concrete type.

@belkadan
Copy link
Contributor

belkadan commented Jun 4, 2019

Do you have a self-contained example? That'll make it a little easier for whoever eventually picks this up. (I agree that the current message is pretty terrible.)

@tayloraswift
Copy link
Contributor Author

struct Model
{
 let int:Int
}
let keyPath:PartialKeyPath<Model> = \.int
var model:Model = .init(int: 0)
let value:Int = model[keyPath: keyPath]

@belkadan
Copy link
Contributor

belkadan commented Jun 5, 2019

Thanks!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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 diagnostics QoI Bug: Diagnostics Quality of Implementation key paths Feature: key paths (both native and Objective-C) type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants