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-9781] Crash on concrete typealias access through existential metatype #52207

Closed
AnthonyLatsis opened this issue Jan 28, 2019 · 9 comments
Closed
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 type checker Area → compiler: Semantic analysis

Comments

@AnthonyLatsis
Copy link
Collaborator

Previous ID SR-9781
Radar None
Original Reporter @AnthonyLatsis
Type Bug
Status Resolved
Resolution Done
Environment

Version 10.1 (10B61)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, StarterBug, TypeChecker
Assignee slazarus (JIRA)
Priority Medium

md5: 6db691761126e55f9148a13cd452e584

relates to:

  • SR-9784 Crash on accessing type alias through protocol-type instance

Issue Description:

protocol P {
  typealias E = Int
}
func foo(meta1: P.Protocol, meta2: P.Type) {
  print(meta1.E.self)
  print(meta2.E.self) // crash
}
@belkadan
Copy link
Contributor

On near-master:

Unhandled coercion
UNREACHABLE executed at /Volumes/Data/swift-public/swift/lib/Sema/CSApply.cpp:6768!
Stack dump:
0.  Program arguments: /Volumes/Data/swift-public/build/ninja/swift-macosx-x86_64/bin/swift -frontend -c -primary-file - -target x86_64-apple-darwin18.5.0 -enable-objc-interop -color-diagnostics -module-name main -o /var/folders/_d/dmrgv26d3bs6lkrks9z825_w0000gn/T/--03f176.o 
1.  While type-checking 'foo(meta1:meta2:)' (at <stdin>:4:1)
2.  While type-checking statement at [<stdin>:4:44 - line:7:1] RangeText="{
  print(meta1.E.self)
  print(meta2.E.self) // crash
"
3.  While type-checking expression at [<stdin>:6:3 - line:6:21] RangeText="print(meta2.E.self"

@xedin, does this look starter-bug-ish to you?

@AnthonyLatsis
Copy link
Collaborator Author

Slava mentions it would be a good starter bug here

@xedin
Copy link
Member

xedin commented Jan 31, 2019

Yeah, I agree with Slava on this one, let's see if anybody steps up to fix this.

@swift-ci
Copy link
Collaborator

swift-ci commented Apr 3, 2019

Comment by Sam Lazarus (JIRA)

I'm happy to pick up the work on this!

@AnthonyLatsis
Copy link
Collaborator Author

slazarus (JIRA User) You most likely want to look somewhere around here

@swift-ci
Copy link
Collaborator

swift-ci commented Apr 4, 2019

Comment by Sam Lazarus (JIRA)

Just put up this PR (#23787). I'm not sure if this is the best way to go about fixing this though. My patch fixes the crashing coercion, but it could be that the type is being incorrectly deduced which is causing the coercion to happen in the first place. If that's the case, then I treated the symptom, not the problem. @AnthonyLatsis Do you think this is the right way to go about fixing this?

@swift-ci
Copy link
Collaborator

swift-ci commented Apr 4, 2019

Comment by Sam Lazarus (JIRA)

Looking into this more as I think I was right that my first attempt was treating a symptom, not the problem. I'll take a look in CSSimplify as per your recommendation and see what i can find.

@AnthonyLatsis
Copy link
Collaborator Author

slazarus (JIRA User) You might find this if statement and its comment interesting. Also, you can force push in this case if you want; no need to start a new PR.

@swift-ci
Copy link
Collaborator

swift-ci commented Apr 5, 2019

Comment by Sam Lazarus (JIRA)

@AnthonyLatsis Reopened and updated the pull request. Thanks for pointing me in the right direction. Hopefully this implementation is a good way of going about this.

@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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

4 participants