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-9675] [SIL] Enum case with closure as associated value crashes SIL #52118

Closed
drexin opened this issue Jan 16, 2019 · 4 comments
Closed

[SR-9675] [SIL] Enum case with closure as associated value crashes SIL #52118

drexin opened this issue Jan 16, 2019 · 4 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 regression swift 5.0

Comments

@drexin
Copy link
Member

drexin commented Jan 16, 2019

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

Ubuntu 18.04 Swift DEVELOPMENT-SNAPSHOT-2019-01-13-a

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, 5.0Regression, CompilerCrash
Assignee @slavapestov
Priority Medium

md5: 2143fec9972936d3e1920e3e034f5702

Issue Description:

The following code works under 4.2, but crashes the SIL under 5.0:

public enum Test {
    case test(f: () -> Void)
}

let x: Test = .test {}
swift: /home/buildnode/jenkins/workspace/oss-swift-5.0-package-linux-ubuntu-18_04/swift/lib/SILGen/SILGenExpr.cpp:2315: swift::Lowering::RValue (anonymous namespace)::RValueEmitter::visitTupleShuffleExpr(swift::TupleShuffleExpr *, swift::Lowering::SGFContext): Assertion `!E->isSourceScalar()' failed.
Stack dump:
0.  Program arguments: /root/.swift/usr/bin/swift -frontend -c -primary-file /code/Sources/Repro/main.swift -emit-module-path /code/.build/x86_64-unknown-linux/debug/Repro.build/main~partial.swiftmodule -emit-module-doc-path /code/.build/x86_64-unknown-linux/debug/Repro.build/main~partial.swiftdoc -emit-dependencies-path /code/.build/x86_64-unknown-linux/debug/Repro.build/main.d -emit-reference-dependencies-path /code/.build/x86_64-unknown-linux/debug/Repro.build/main.swiftdeps -target x86_64-unknown-linux -disable-objc-interop -sdk / -I /code/.build/x86_64-unknown-linux/debug -I /code/Sources/CRepro/include -enable-testing -g -module-cache-path /code/.build/x86_64-unknown-linux/debug/ModuleCache -swift-version 4 -Onone -D SWIFT_PACKAGE -D DEBUG -color-diagnostics -Xcc -fmodule-map-file=/code/.build/x86_64-unknown-linux/debug/CRepro.build/module.modulemap -module-name Repro -o /code/.build/x86_64-unknown-linux/debug/Repro.build/main.swift.o -index-store-path /code/.build/x86_64-unknown-linux/debug/index/store -index-system-modules
@belkadan
Copy link
Contributor

cc CodaFi (JIRA User), @jckarter, @slavapestov

@slavapestov
Copy link
Member

It only crashes if you use the trailing closure syntax. It appears that '.test(f: {})' works.

@drexin
Copy link
Member Author

drexin commented Jan 16, 2019

@slavapestov Thanks, I hadn't tested that. It also seems to work fine with unlabeled parameters, i.e.

public enum Test {
    case test(_ f: () -> Void)
}

let x: Test = .test {}

@slavapestov
Copy link
Member

#21927

@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 regression swift 5.0
Projects
None yet
Development

No branches or pull requests

4 participants