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-2544] Compiler crash on access to protocol function #45149

Closed
krzyzanowskim opened this issue Sep 1, 2016 · 7 comments
Closed

[SR-2544] Compiler crash on access to protocol function #45149

krzyzanowskim opened this issue Sep 1, 2016 · 7 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software

Comments

@krzyzanowskim
Copy link
Contributor

Previous ID SR-2544
Radar None
Original Reporter @krzyzanowskim
Type Bug
Status Resolved
Resolution Duplicate

Attachment: Download

Environment

Xcode 8 beta6

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

md5: 66a08045e4bc3b82814f31c480610389

duplicates:

  • SR-75 Referencing a protocol function crashes the compiler

Issue Description:

The code below is invalid and cause Signal 11 crash

protocol Test {
    func foo()
}

let p = Test.foo

Xcode is not helping here too (see attached screenshot), this suggestion should never happen as it's nothing that can be actually used.

@belkadan
Copy link
Contributor

belkadan commented Sep 1, 2016

@benlangmuir, is it also worth getting this out of code completion until we actually implement support for it?

@belkadan
Copy link
Contributor

belkadan commented Sep 1, 2016

@slavapestov, do you have the Radar that goes with this?

@benlangmuir
Copy link
Member

If you want to ban this until it's fixed in SILGen, it should be done in the type-checker so users get a diagnostic (this code currently passes swiftc -parse). That should make code-completion do the right thing as well.

@belkadan
Copy link
Contributor

belkadan commented Sep 1, 2016

Why would that make code completion do the right thing?

@krzyzanowskim
Copy link
Contributor Author

@belkadan I'm just curious, how would you add support for that? what it would point to if there is no implementation (just definition) and what is the use case for that?

the use I can think of is like this:

class T: Test {
  func foo() { }
}

let t = T()
Test.foo(t) // call T.foo

@belkadan
Copy link
Contributor

belkadan commented Sep 1, 2016

That's how it would work: you'd have to pass a concrete instance with protocol type, and then it would dynamically call that on that instance. That's how it works for classes with overridable methods.

@benlangmuir
Copy link
Member

Oh my mistake, we'd probably need to tweak a condition in isDeclVisibleInLookupMode. Anyway, the answer to "should we ban this" should be the same in code-completion and type-checking...

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 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 crash Bug: A crash, i.e., an abnormal termination of software
Projects
None yet
Development

No branches or pull requests

4 participants