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-11636] Accessing covariant Self from stored property initializer in extension segfaults #54047

Closed
DeFrenZ opened this issue Oct 18, 2019 · 11 comments
Assignees
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 good first issue Good for newcomers

Comments

@DeFrenZ
Copy link

DeFrenZ commented Oct 18, 2019

Previous ID SR-11636
Radar rdar://problem/56467142
Original Reporter @DeFrenZ
Type Bug
Status Resolved
Resolution Done
Environment

Xcode 11.1 (11A1027)

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

md5: 95fa6dd3261c88c421192579e14d986d

is duplicated by:

  • SR-11689 Segmentation fault referring to Self in class extension

Issue Description:

This crashes the compiler

class Foo {}
extension Foo {
    static let foo = "\(Self.self)"
}

Doing the same but without the extension gives the correct (I believe) error

@belkadan
Copy link
Contributor

@slavapestov, think this would be a good starter bug?

@belkadan
Copy link
Contributor

@swift-ci create

@slavapestov
Copy link
Member

Yes, the fact that we correctly diagnose a class member but crash on an extension member suggests that this is a matter if tracking down an incorrect `isa<>` check. Definitely a good starter bug candidate.

@swift-ci
Copy link
Collaborator

Comment by Ziyuan Zhao (JIRA)

I'd like to fix this problem. Where should I start? @slavapestov

@theblixguy
Copy link
Collaborator

The error is emitted by TypeChecker::checkPatternBindingCaptures, so perhaps you can start from there. It doesn't seem like it's called for a ExtensionDecl, so one way to fix it would be to change checkPatternBindingCaptures to accept a IterableDeclContext rather than a NominalTypeDecl and then calling TypeChecker::checkPatternBindingCaptures(ED) in visitExtensionDecl in TypeCheckDecl.cpp.

@swift-ci
Copy link
Collaborator

Comment by Ziyuan Zhao (JIRA)

It seems that the duplicated issue SR-11689 has been fixed. Also I'v tested with the latest Swift code and it works fine. So I think this issue should be closed too.

@slavapestov
Copy link
Member

ninjiacoder (JIRA User) The bug is definitely still present in the latest master. @theblixguy's explanation for how to fix the problem is the correct one. Let me know if you still want to attempt this.

@swift-ci
Copy link
Collaborator

Comment by Ziyuan Zhao (JIRA)

@slavapestov Sure. I still want to fix it.

@CodaFi
Copy link
Member

CodaFi commented Nov 20, 2019

ninjiacoder (JIRA User) Sorry, I took this one over on #28392 We got an unrelated bug report and I didn't see this issue already had somebody assigned...

@swift-ci
Copy link
Collaborator

Comment by Ziyuan Zhao (JIRA)

@CodaFi Never mind. Glad to hear that it's fixed! 🙂

@CodaFi
Copy link
Member

CodaFi commented Nov 21, 2019

Resolved by the merge of #28392

@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 good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

7 participants