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

Comments

@AnthonyLatsis
Copy link
Collaborator

@AnthonyLatsis AnthonyLatsis commented Jan 28, 2019

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

@belkadan belkadan commented Jan 28, 2019

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

@AnthonyLatsis AnthonyLatsis commented Jan 28, 2019

Slava mentions it would be a good starter bug here

@xedin
Copy link
Member

@xedin 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 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

@AnthonyLatsis AnthonyLatsis commented Apr 3, 2019

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

@swift-ci
Copy link
Collaborator

@swift-ci 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 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

@AnthonyLatsis AnthonyLatsis commented Apr 4, 2019

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 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
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants