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-895] Cannot do a qualified import of an operator #43507

Open
mbrandonw opened this issue Mar 7, 2016 · 6 comments
Open

[SR-895] Cannot do a qualified import of an operator #43507

mbrandonw opened this issue Mar 7, 2016 · 6 comments
Labels
compiler The Swift compiler in itself improvement parser Area → compiler: The legacy C++ parser

Comments

@mbrandonw
Copy link
Contributor

Previous ID SR-895
Radar None
Original Reporter @mbrandonw
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, Parser
Assignee None
Priority Medium

md5: 27e10ef68b7c68f6c948acacbf246aa2

relates to:

  • SR-8278 Syntax to disambiguate operators

Issue Description:

When I try to do a qualified import of a function that happens to be an operator, e.g.

import func Argo.<|

I get the following error:

Expected module name in import declaration.

This still works for non-operator, free functions:

import Argo.decode

Is this supposed to be supported in Swift 2.2?

@belkadan
Copy link
Contributor

belkadan commented Mar 8, 2016

Pretty sure we've never supported this, just in the parser. It's a reasonable enhancement to the feature, although honestly I'm still unhappy with having this feature at all rather than something like @qualified import.

@belkadan
Copy link
Contributor

belkadan commented Mar 8, 2016

Importing .. would certainly look weird. import Foo.... Maybe you'd have to use backticks.

@mbrandonw
Copy link
Contributor Author

Ah, good to know

Is there that big of a distinction between functions and operators that `import func Module.functionName` would be supported, but not importing an operator?

@belkadan
Copy link
Contributor

belkadan commented Mar 8, 2016

No, no reason. There's a difference between operator functions and the operator decls themselves, but (IIRC) the operator decls currently leak in no matter what you do. This would only apply to the functions and so would behave pretty much exactly like the normal function case. We just don't even attempt to parse an operator following the dot.

@swift-ci
Copy link
Collaborator

swift-ci commented Jul 2, 2016

Comment by Nikita Leonov (JIRA)

@belkadan the fact that operators disregard importing rules and leaks is really frustrating. I was not able to find a way to import just a function from a library and do not import operators. Is it subject to change in Swift 3?

@belkadan
Copy link
Contributor

belkadan commented Jul 5, 2016

It is not at the moment. Please bring it up on swift-evolution if you have an alternate model. (That's also separate from this bug.)

@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
compiler The Swift compiler in itself improvement parser Area → compiler: The legacy C++ parser
Projects
None yet
Development

No branches or pull requests

3 participants