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-1725] Assertion failed: ((HadError || !M.is<SourceFile*>() || M.get<SourceFile*>()->ASTStage < SourceFile::TypeChecked) && "UnresolvedDot" "in wrong phase") #44334
Comments
Comment by Quildreen Motta (JIRA) Unsure if the cause is the same, but this causes the same crash: struct Task<S, E> {
typealias Fork = ((S) -> Void, (E) -> Void) -> Void
let fork: Fork
init(fork: Fork) { self.fork = fork }
func flatMap<S2>(transform: (S) -> Task<S2, E>) -> Task<S2, E> {
let task = self
return Task { resolve, reject in
task.fork({
v in transform(v).fork({ v2 in resolve(v2) }, { e in reject(e) })
},
{
e in reject(e)
})
}
}
} This happens both on the preview and on the latest snapshot: Swift version 3.0 (swift-3.0-PREVIEW-1) Swift version 3.0-dev (LLVM cb08d1dbbd, Clang 383859a9c4, Swift 9e8266a) |
Ok, the CSDiag.cpp stuff is creating an expression with ErrorType, but failing to emit any diagnostics. I guess there's a missing case here. If I remove most of the closure contents, the actual bug is this: cr.swift:9:12: error: cannot convert return expression of type 'Task<S, E>' to return type 'Task<S2, E>' Arguably, we should be smarter about resolving the generic parameters of 'Task' here. Referencing a generic without arguments is handled via two cases:
I think in addition to fixing the diagnostic logic here, we should be doing #2 if #1 fails, but this is a bit tricky. In any case, to make your code work, change 'return Task {' to 'return Task<S2, E> {'. |
Over to Chris for properly emitting the diagnostic. |
This crash showed up for me in the latest development toolchain (2016-08-29) using the following snippet: struct Tester { var value: Int }
let c: (Tester) -> Void = { t in { [v = t.value] in }() } As far as I can tell, the key seems to be the inner closure's capture list specifying an ivar of the outer closure's parameter. This further-reduced case also crashes, but with a different trace: struct Tester {}
let c: (Tester) -> Void = { t in { [v = t] in }() } The trace in this case is: non-canonical or unchecked type
UNREACHABLE executed at /Users/buildnode/jenkins/workspace/oss-swift-package-osx/swift/include/swift/AST/CanTypeVisitor.h:41!
...
Thread 7 Crashed:: lldb.debugger.io-handler
0 libsystem_kernel.dylib 0x00007fff91392f06 __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff8ac3e4ec pthread_kill + 90
2 com.apple.LLDB.framework 0x000000010cf48a1e abort + 14 (Signals.inc:439)
3 com.apple.LLDB.framework 0x000000010cef2237 llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) + 471
4 com.apple.LLDB.framework 0x000000010d99461d swift::Lowering::ManagedValue swift::CanTypeVisitor<(anonymous namespace)::EmitBBArguments, swift::Lowering::ManagedValue>::visit<>(swift::CanType) + 1773 (Type.h:245)
5 com.apple.LLDB.framework 0x000000010d993244 swift::Lowering::SILGenFunction::emitProlog(llvm::ArrayRef<swift::ParameterList*>, swift::Type, swift::DeclContext*) + 404 (SILGenProlog.cpp:236)
6 com.apple.LLDB.framework 0x000000010d99265e swift::Lowering::SILGenFunction::emitProlog(swift::AnyFunctionRef, llvm::ArrayRef<swift::ParameterList*>, swift::Type) + 94 (SILGenProlog.cpp:427)
7 com.apple.LLDB.framework 0x000000010d956dbc swift::Lowering::SILGenFunction::emitClosure(swift::AbstractClosureExpr*) + 108 (SILGenFunction.cpp:486)
8 com.apple.LLDB.framework 0x000000010d8f00ea swift::Lowering::SILGenModule::emitClosure(swift::AbstractClosureExpr*) + 266 (SILGen.cpp:809)
9 com.apple.LLDB.framework 0x000000010d94df69 (anonymous namespace)::RValueEmitter::visitAbstractClosureExpr(swift::AbstractClosureExpr*, swift::Lowering::SGFContext) + 41 (SILGenExpr.cpp:1933)
10 com.apple.LLDB.framework 0x000000010d943fa3 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 131 (ASTVisitor.h:69)
11 com.apple.LLDB.framework 0x000000010d93f1c0 swift::Lowering::SILGenFunction::emitExprInto(swift::Expr*, swift::Lowering::Initialization*) + 304 (SILGenExpr.cpp:104)
12 com.apple.LLDB.framework 0x000000010d92f2b5 swift::Lowering::SILGenFunction::emitPatternBinding(swift::PatternBindingDecl*, unsigned int) + 213 (SILGenDecl.cpp:992)
13 com.apple.LLDB.framework 0x000000010d92f3ad swift::Lowering::SILGenFunction::visitPatternBindingDecl(swift::PatternBindingDecl*) + 45 (SILGenDecl.cpp:1002)
14 com.apple.LLDB.framework 0x000000010d8f308c swift::Lowering::SILGenModule::visitTopLevelCodeDecl(swift::TopLevelCodeDecl*) + 220 (SILGen.cpp:1203)
15 com.apple.LLDB.framework 0x000000010d8f386b swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 715 (SILGen.cpp:1407)
16 com.apple.LLDB.framework 0x000000010d8f4765 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 949 (SILGen.cpp:1441)
17 com.apple.LLDB.framework 0x000000010d8f4c55 swift::performSILGeneration(swift::FileUnit&, swift::SILOptions&, llvm::Optional<unsigned int>, bool) + 117 (SILGen.cpp:1505)
18 com.apple.LLDB.framework 0x000000010de818da lldb_private::SwiftExpressionParser::Parse(lldb_private::DiagnosticManager&, unsigned int, unsigned int, unsigned int) + 14348 (SwiftExpressionParser.cpp:1729)
19 com.apple.LLDB.framework 0x000000010dec3583 lldb_private::SwiftUserExpression::Parse(lldb_private::DiagnosticManager&, lldb_private::ExecutionContext&, lldb_private::ExecutionPolicy, bool, bool, unsigned int) + 825 (SwiftUserExpression.cpp:511)
20 com.apple.LLDB.framework 0x000000010dc8cf20 lldb_private::UserExpression::Evaluate(lldb_private::ExecutionContext&, lldb_private::EvaluateExpressionOptions const&, char const*, char const*, lldb_private::SharingPtr<lldb_private::ValueObject>&, lldb_private::Error&, unsigned int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, std::__1::shared_ptr<lldb_private::Module>*) + 1064 (UserExpression.cpp:270)
21 com.apple.LLDB.framework 0x000000010db7c48c lldb_private::REPL::IOHandlerInputComplete(lldb_private::IOHandler&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) + 1612 (REPL.cpp:359)
22 com.apple.LLDB.framework 0x000000010dc006f3 lldb_private::IOHandlerEditline::Run() + 383 (IOHandler.cpp:698)
23 com.apple.LLDB.framework 0x000000010daee6a9 lldb_private::Debugger::ExecuteIOHandlers() + 63 (Debugger.cpp:1020)
24 com.apple.LLDB.framework 0x000000010daf06ee lldb_private::Debugger::IOHandlerThread(void*) + 14 (Debugger.cpp:1844)
25 libsystem_pthread.dylib 0x00007fff8ac3b99d _pthread_body + 131
26 libsystem_pthread.dylib 0x00007fff8ac3b91a _pthread_start + 168
27 libsystem_pthread.dylib 0x00007fff8ac39351 thread_start + 13 |
@gwynne the bug you're describing is different I think, it's https://bugs.swift.org/browse/SR-5870. |
@ddunbar your original example no longer crashes. Instead it fails to type check with
This is a lousy diagnostic but we have a number of bugs concerning closure diagnostics already so I'll just close this one. |
Attachment: Download
Additional Detail from JIRA
md5: 87e835799ceb9cf29e7c3d4815d3ba1c
relates to:
Issue Description:
Swift TOT crashes on this code:
The text was updated successfully, but these errors were encountered: