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-7] Inferring closure param type to inout crashes compiler #42633

Closed
jopamer opened this issue Nov 6, 2015 · 3 comments
Closed

[SR-7] Inferring closure param type to inout crashes compiler #42633

jopamer opened this issue Nov 6, 2015 · 3 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@jopamer
Copy link
Contributor

jopamer commented Nov 6, 2015

Previous ID SR-7
Radar rdar://problem/22813050
Original Reporter @jopamer
Type Bug
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee @gregomni
Priority Medium

md5: 706aa076b5d0c32439e4d8e8563b7862

Issue Description:

If you attempt to compile the following program, the compiler crashes:

func f(inout a: Int) {}
let g = { x in f(x) }
@lilyball
Copy link
Mannequin

lilyball mannequin commented Dec 4, 2015

Debug stack trace (Swift version 2.2-dev (LLVM 46be9ff861, Clang 4deb154edc, Swift e8a15c6)):

Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file /Users/kevin/Dev/Swift/Apple/llvm/include/llvm/Support/Casting.h, line 237.
0  swift                    0x000000010e392f0e llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 46
1  swift                    0x000000010e393359 PrintStackTraceSignalHandler(void*) + 25
2  swift                    0x000000010e38faf9 llvm::sys::RunSignalHandlers() + 425
3  swift                    0x000000010e393699 SignalHandler(int) + 345
4  libsystem_platform.dylib 0x00007fff8efca52a _sigtramp + 26
5  libsystem_platform.dylib 0x0000ffff00001fa0 _sigtramp + 1896053392
6  swift                    0x000000010e39337b raise + 27
7  swift                    0x000000010e393432 abort + 18
8  swift                    0x000000010e393411 __assert_rtn + 129
9  swift                    0x000000010a141557 llvm::cast_retty<swift::InOutExpr, swift::Expr*>::ret_type llvm::cast<swift::InOutExpr, swift::Expr>(swift::Expr*) + 103
10 swift                    0x0000000109240ac3 (anonymous namespace)::ArgEmitter::emitInOut(swift::Lowering::ArgumentSource&&, swift::SILType, swift::SILType, swift::Lowering::AbstractionPattern, swift::CanType)::'lambda'()::operator()() const + 547
11 swift                    0x000000010923c21f (anonymous namespace)::ArgEmitter::emitInOut(swift::Lowering::ArgumentSource&&, swift::SILType, swift::SILType, swift::Lowering::AbstractionPattern, swift::CanType) + 127
12 swift                    0x000000010923b32f (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 879
13 swift                    0x000000010923a9f0 (anonymous namespace)::ArgEmitter::emitTopLevel(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 128
14 swift                    0x0000000109239c03 (anonymous namespace)::CallSite::emit(swift::Lowering::SILGenFunction&, swift::Lowering::AbstractionPattern, (anonymous namespace)::ParamLowering&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, llvm::SmallVectorImpl<std::__1::pair<swift::Lowering::LValue, swift::SILLocation> >&, llvm::Optional<swift::ForeignErrorConvention> const&) && + 563
15 swift                    0x0000000109224cc3 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 4403
16 swift                    0x0000000109223576 swift::Lowering::SILGenFunction::emitApplyExpr(swift::Expr*, swift::Lowering::SGFContext) + 166
17 swift                    0x00000001092aa1f2 (anonymous namespace)::RValueEmitter::visitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 66
18 swift                    0x00000001092a083a swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visitCallExpr(swift::CallExpr*, swift::Lowering::SGFContext) + 74
19 swift                    0x0000000109299833 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 3699
20 swift                    0x0000000109291df9 swift::Lowering::SILGenFunction::emitRValue(swift::Expr*, swift::Lowering::SGFContext) + 201
21 swift                    0x000000010934d2bf swift::Lowering::SILGenFunction::emitReturnExpr(swift::SILLocation, swift::Expr*) + 895
22 swift                    0x000000010934e682 (anonymous namespace)::StmtEmitter::visitReturnStmt(swift::ReturnStmt*) + 626
23 swift                    0x000000010934c683 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 115
24 swift                    0x000000010934e2d0 (anonymous namespace)::StmtEmitter::visitBraceStmt(swift::BraceStmt*) + 784
25 swift                    0x000000010934c66b swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 91
26 swift                    0x000000010934c5d0 swift::Lowering::SILGenFunction::emitStmt(swift::Stmt*) + 48
27 swift                    0x00000001092c27e1 swift::Lowering::SILGenFunction::emitClosure(swift::AbstractClosureExpr*) + 401
28 swift                    0x00000001091edf51 swift::Lowering::SILGenModule::emitClosure(swift::AbstractClosureExpr*) + 401
29 swift                    0x00000001092a80aa (anonymous namespace)::RValueEmitter::visitAbstractClosureExpr(swift::AbstractClosureExpr*, swift::Lowering::SGFContext) + 154
30 swift                    0x000000010929df8a swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visitClosureExpr(swift::ClosureExpr*, swift::Lowering::SGFContext) + 74
31 swift                    0x0000000109299545 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 2949
32 swift                    0x0000000109291df9 swift::Lowering::SILGenFunction::emitRValue(swift::Expr*, swift::Lowering::SGFContext) + 201
33 swift                    0x0000000109291c90 swift::Lowering::SILGenFunction::emitExprInto(swift::Expr*, swift::Lowering::Initialization*) + 272
34 swift                    0x000000010926d3da swift::Lowering::SILGenFunction::emitPatternBinding(swift::PatternBindingDecl*, unsigned int) + 442
35 swift                    0x000000010926d62f swift::Lowering::SILGenFunction::visitPatternBindingDecl(swift::PatternBindingDecl*) + 159
36 swift                    0x0000000109204a1c swift::ASTVisitor<swift::Lowering::SILGenFunction, void, void, void, void, void, void>::visit(swift::Decl*) + 140
37 swift                    0x00000001091f1220 swift::Lowering::SILGenModule::visitTopLevelCodeDecl(swift::TopLevelCodeDecl*) + 624
38 swift                    0x000000010920564c swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 188
39 swift                    0x00000001091f15bc swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 220
40 swift                    0x00000001091f19b9 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 873
41 swift                    0x00000001091f2337 swift::performSILGeneration(swift::FileUnit&, swift::SILOptions&, llvm::Optional<unsigned int>, bool) + 135
42 swift                    0x0000000108cc435f performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 7007
43 swift                    0x0000000108cc1f2c frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 12812
44 swift                    0x0000000108ca938d main + 4285
45 libdyld.dylib            0x00007fff933e95ad start + 1
46 libdyld.dylib            0x000000000000000d start + 1824615009
Stack dump:
0.  Program arguments: /Users/kevin/Dev/Swift/Apple/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swift -frontend -c -primary-file foo.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -color-diagnostics -module-name foo -o /var/folders/cs/l6c6g06x0974_0w5pdg8dps80000gn/T/foo-3dfd86.o 
1.  While silgen closureexpr SIL function @_TF3fooU_FRSiT_ for expression at [foo.swift:2:9 - line:2:21] RangeText="{ x in f(x) }"

@gregomni
Copy link
Collaborator

gregomni commented Dec 6, 2015

I've submitted a pull request that fixes this bug at <https://github.com/apple/swift/pull/274\>.

@gregomni
Copy link
Collaborator

Fixed and merged via <https://github.com/apple/swift/pull/274\>.

@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
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

2 participants