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-493] Compiler crashes when Implementing ArrayLitteralConvertible In a generic struct #43110

Closed
swift-ci opened this issue Jan 7, 2016 · 1 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

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jan 7, 2016

Previous ID SR-493
Radar None
Original Reporter swiftyjay (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment

osx 10.11.2 xcode 7.2, swift 2.1.1

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

md5: 9f212dadba14e8dc456ba64d54a8dee6

duplicates:

  • SR-488 Crash when emitting store into a generic member, from initializer in an extension

relates to:

  • SR-488 Crash when emitting store into a generic member, from initializer in an extension

Issue Description:

Sample code (crashing) :

struct L<Element> {
    var l1: Element?
}

extension L: ArrayLiteralConvertible {
    init(arrayLiteral elements: Element...) {
        l1 = elements.first!
    }
}

I tested a lot of cases and after trial and error found workarounds:

  • if l1 is a let instead of a var, compilation succeeds

  • if the base constructor is called, compilation succeeds

Best workaround - call base constructor :

Working

struct L<Element> {
    var l1: Element?
}

extension L: ArrayLiteralConvertible {
    init(arrayLiteral elements: Element...) {
        self.init(l1: elements.first!)
    }
}

Thanks for the good work

@jtbandes
Copy link
Collaborator

With some experimentation I'm convinced that this is just a bug with emitting a store into the property (which is avoided by delegating to another initializer); it's the same as SR-488.

@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

3 participants