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-10517] Imported C Structs can't be subscripted with KeyPath #52917

Closed
swift-ci opened this issue Apr 19, 2019 · 1 comment
Closed

[SR-10517] Imported C Structs can't be subscripted with KeyPath #52917

swift-ci opened this issue Apr 19, 2019 · 1 comment
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

@swift-ci
Copy link
Collaborator

Previous ID SR-10517
Radar None
Original Reporter george (JIRA User)
Type Bug
Status Closed
Resolution Invalid

Attachment: Download

Environment

Xcode 10.2.1

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

md5: 71d802c8fef3eec1fbbfd9fc8dcdf5d1

Issue Description:

// C header

typedef struct { unsigned char c; } foo;

// Swift

let x = foo(c: 0)

let kp = \foo.c

let c = foo[kp] // value of type 'foo.Type' has no subscripts

I expect `foo[kp]` to return 0

@belkadan
Copy link
Contributor

It's x[keyPath: kp], not just foo[kp], but the compiler should probably have a special-case diagnostic for both of these: using an instance key path on a type, and using a key path without a label when the type doesn't have an unlabeled subscript that takes a key path.

cc @xedin, @jckarter

@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 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