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-9862] SE-0044 import as subscript does not work #52269

Open
martinr448 opened this issue Feb 4, 2019 · 2 comments
Open

[SR-9862] SE-0044 import as subscript does not work #52269

martinr448 opened this issue Feb 4, 2019 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@martinr448
Copy link

Previous ID SR-9862
Radar None
Original Reporter @martinr448
Type Bug
Environment

Tested with Xcode 10.2 beta (10P82s).

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

md5: f75807e11fe8455585f2e10894fdd756

Issue Description:

The ”import as subscript” from SE-0044 Import as member does not work. Example:

// CFile.h:

typedef struct Point3D {
    float x;
    float y;
    float z;
} Point3D;

float Point3DGetPointAtIndex(Point3D point, int idx)
__attribute__((swift_name("getter:Point3D.subscript(self:_:)")));

// main.swift:

let p = Point3D()
let x = p[0];
// Error: Value of type 'Point3D' has no subscripts

let y = Point3DGetPointAtIndex(p, 0)
// 'Point3DGetPointAtIndex' has been replaced by property 'Point3D.subscript'

Apparently, the function is imported as a property named "subscript."

Related discussion in the Swift forum: Import C functions as subscript methods (follow-up).

@belkadan
Copy link
Contributor

belkadan commented Feb 5, 2019

Ah, I figured this would be a regression, but looking at the code I think it was just never implemented. Not quite a starter bug, then, since there's likely to be issues with just doing the "obvious" thing.

@beccadax
Copy link
Contributor

beccadax commented Sep 1, 2020

@swift-ci cretae

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

No branches or pull requests

3 participants