Skip to content

[SR-10492] Paren'd reference to an IUO function crashes compiler #52892

Closed
@hamishknight

Description

@hamishknight
Previous ID SR-10492
Radar rdar://problem/50169820
Original Reporter @hamishknight
Type Bug
Status Closed
Resolution Done
Environment

Swift version 5.0-dev (LLVM 94d957ca75, Swift 130cd9e81f)
Target: x86_64-apple-darwin18.5.0

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

md5: 8ee4e902782100dc63e3cfb2c3cdbe6c

Issue Description:

The following hits an unreachable in SILGen:

struct S {
  func foo() -> Int! { return 0 }
}

let s = S()
let x: Int = (s.foo)()

Stack Dump:

We should not see ImplicitlyUnwrappedFunctionConversionExpr here
UNREACHABLE executed at /Users/hamishknight/Desktop/swift-dev/swift/lib/SILGen/SILGenApply.cpp:1232!
Stack dump:
0.  Program arguments: ./swift -frontend -emit-silgen /Users/hamishknight/Desktop/Stochastic Projects/newnew/newnew/main.swift -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
0  swift                    0x0000000111429585 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x0000000111428588 llvm::sys::RunSignalHandlers() + 248
2  swift                    0x0000000111429b88 SignalHandler(int) + 264
3  libsystem_platform.dylib 0x00007fff61b98b5d _sigtramp + 29
4  libsystem_platform.dylib 0x0000000000000046 _sigtramp + 2655417606
5  libsystem_c.dylib        0x00007fff61a586a6 abort + 127
6  swift                    0x000000011139c53c llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) + 540
7  swift                    0x000000010d9d484c (anonymous namespace)::SILGenApply::visitImplicitlyUnwrappedFunctionConversionExpr(swift::ImplicitlyUnwrappedFunctionConversionExpr*) + 28
8  swift                    0x000000010d9d4370 swift::ASTVisitor<(anonymous namespace)::SILGenApply, void, void, void, void, void, void>::visit(swift::Expr*) + 7008
9  swift                    0x000000010d9d6932 (anonymous namespace)::SILGenApply::visitApplyExpr(swift::ApplyExpr*) + 2402
10 swift                    0x000000010d9bdfa7 swift::Lowering::SILGenFunction::emitApplyExpr(swift::Expr*, swift::Lowering::SGFContext) + 135
11 swift                    0x000000010da26eef swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 79
12 swift                    0x000000010da18d2f swift::Lowering::SILGenFunction::emitExprInto(swift::Expr*, swift::Lowering::Initialization*, llvm::Optional<swift::SILLocation>) + 303
13 swift                    0x000000010da07d65 swift::Lowering::SILGenFunction::emitPatternBinding(swift::PatternBindingDecl*, unsigned int) + 325
14 swift                    0x000000010da07e6d swift::Lowering::SILGenFunction::visitPatternBindingDecl(swift::PatternBindingDecl*) + 45
15 swift                    0x000000010d9b2f59 swift::Lowering::SILGenModule::visitTopLevelCodeDecl(swift::TopLevelCodeDecl*) + 505
16 swift                    0x000000010d9b37a6 swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*) + 806
17 swift                    0x000000010d9b47a8 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*) + 376
18 swift                    0x000000010d9b4c90 swift::performSILGeneration(swift::ModuleDecl*, swift::SILOptions&) + 16
19 swift                    0x000000010d6bd49a performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 10266
20 swift                    0x000000010d6b9c26 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2982
21 swift                    0x000000010d660af8 main + 696
22 libdyld.dylib            0x00007fff619b33d5 start + 1
fish: './swift -frontend -emit-silgen…' terminated by signal SIGABRT (Abort)

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of software

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions