Navigation Menu

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-11681] Segfault when emitting SIL for Generic specialized to Self #54090

Closed
swift-ci opened this issue Oct 30, 2019 · 4 comments
Closed

[SR-11681] Segfault when emitting SIL for Generic specialized to Self #54090

swift-ci opened this issue Oct 30, 2019 · 4 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

@swift-ci
Copy link
Collaborator

Previous ID SR-11681
Radar rdar://problem/56747659
Original Reporter benpious (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Swift 5.1, Xcode 11.1

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

md5: 893a0517d6b87a11744a40e54193a693

Issue Description:

The following code crashes the compiler. It has no dependencies, you can paste it into a file and run `swiftc` to see the bug.

struct S<T> {
    let boxed: T
}

class C {
    private(set) lazy var s = S<Self>(boxed: self as! Self)
}

I originally thought that adding final to C should stop the crashes, but even then the crash still occurs. This gives me hope that maybe this should have been allowed to type-check even without the as!, since I don't see a difference between returning Self and returning S<Self>.

Interestingly, private(set) lazy var s = S<Self>(boxed: self) doesn't type check even when C is final, as the compiler claims that it can't convert a value of type C to type Self, which doesn't make much sense to me, since it isn't even possible for Self to be a subclass of C in that context.

@belkadan
Copy link
Contributor

@swift-ci create

@theblixguy
Copy link
Collaborator

On master, I get:

/Users/suyashsrijan/Desktop/test.swift:6:25: error: covariant 'Self' can only appear at the top level of property type
  private(set) lazy var s = S<Self>(boxed: self as! Self)
                        ^
/Users/suyashsrijan/Desktop/test.swift:6:25: error: mutable property cannot have covariant 'Self' type
  private(set) lazy var s = S<Self>(boxed: self as! Self)
                        ^
/Users/suyashsrijan/Desktop/test.swift:6:25: error: covariant 'Self' can only appear at the top level of method result type
  private(set) lazy var s = S<Self>(boxed: self as! Self)
                        ^
/Users/suyashsrijan/Desktop/test.swift:6:25: error: covariant 'Self' can only appear at the top level of property type
  private(set) lazy var s = S<Self>(boxed: self as! Self)
                        ^
/Users/suyashsrijan/Desktop/test.swift:6:25: error: stored property cannot have covariant 'Self' type
  private(set) lazy var s = S<Self>(boxed: self as! Self)

@beccadax
Copy link
Contributor

beccadax commented Nov 1, 2019

Likewise, I can reproduce this in Xcode 11.2 but not in master.

@slavapestov
Copy link
Member

#29682

@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

6 participants