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-9508] Compiler Crash with typealias in constrained extension #51961
Comments
I don't think this ever worked the way you wanted, so maybe it's a good thing it crashed.
|
I think you are showing a different bug with the let x: line. The code I showed should be valid, and it worked correctly with Swift 4.2. Your example is invalid code that actually compiles with Swift 4.2: while the typealias is defined in a constrained extension, it is incorrectly visible globally. Is this already known or should I report it in a separate issue? To crash with Swift 4.2 you need to make it slightly more convoluted: protocol Q {
associatedtype R
}
extension S3 where G: Q {
typealias C = G.R
}
let y: S3<S1>.C = nil This does indeed crash with Swift 4.2, but with Development Snapshot 2018-12-10 the assert is different from what I showed above, adding further evidence that this is a different bug: checked decl cannot have error type
(var_decl range=[/Users/nicolasalmoria/Documents/BugReportCompilerCrash4/VeniceConnection/main.swift:31:5 - line:31:5] "y" type='<<error type>>' interface type='<<error type>>' access=internal let readImpl=stored immutable)
Stack dump:
0. Program arguments: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2018-12-10-a.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/nicolasalmoria/Documents/BugReportCompilerCrash4/VeniceConnection/main.swift -emit-module-path /Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/SR-9508-djsdvfrplcpmqyeevggkxowuhkvk/Build/Intermediates.noindex/SR-9508.build/Debug/SR-9508.build/Objects-normal/x86_64/main~partial.swiftmodule -emit-module-doc-path /Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/SR-9508-djsdvfrplcpmqyeevggkxowuhkvk/Build/Intermediates.noindex/SR-9508.build/Debug/SR-9508.build/Objects-normal/x86_64/main~partial.swiftdoc -serialize-diagnostics-path /Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/SR-9508-djsdvfrplcpmqyeevggkxowuhkvk/Build/Intermediates.noindex/SR-9508.build/Debug/SR-9508.build/Objects-normal/x86_64/main.dia -emit-dependencies-path /Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/SR-9508-djsdvfrplcpmqyeevggkxowuhkvk/Build/Intermediates.noindex/SR-9508.build/Debug/SR-9508.build/Objects-normal/x86_64/main.d -emit-reference-dependencies-path /Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/SR-9508-djsdvfrplcpmqyeevggkxowuhkvk/Build/Intermediates.noindex/SR-9508.build/Debug/SR-9508.build/Objects-normal/x86_64/main.swiftdeps -target x86_64-apple-macosx10.13 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I /Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/SR-9508-djsdvfrplcpmqyeevggkxowuhkvk/Build/Products/Debug -F /Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/SR-9508-djsdvfrplcpmqyeevggkxowuhkvk/Build/Products/Debug -enable-testing -g -module-cache-path /Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 4.2 -enforce-exclusivity=checked -Onone -D DEBUG -serialize-debugging-options -Xcc -I/Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/SR-9508-djsdvfrplcpmqyeevggkxowuhkvk/Build/Intermediates.noindex/SR-9508.build/Debug/SR-9508.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/SR-9508-djsdvfrplcpmqyeevggkxowuhkvk/Build/Intermediates.noindex/SR-9508.build/Debug/SR-9508.build/SR-9508-generated-files.hmap -Xcc -I/Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/SR-9508-djsdvfrplcpmqyeevggkxowuhkvk/Build/Intermediates.noindex/SR-9508.build/Debug/SR-9508.build/SR-9508-own-target-headers.hmap -Xcc -I/Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/SR-9508-djsdvfrplcpmqyeevggkxowuhkvk/Build/Intermediates.noindex/SR-9508.build/Debug/SR-9508.build/SR-9508-all-target-headers.hmap -Xcc -iquote -Xcc /Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/SR-9508-djsdvfrplcpmqyeevggkxowuhkvk/Build/Intermediates.noindex/SR-9508.build/Debug/SR-9508.build/SR-9508-project-headers.hmap -Xcc -I/Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/SR-9508-djsdvfrplcpmqyeevggkxowuhkvk/Build/Products/Debug/include -Xcc -I/Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/SR-9508-djsdvfrplcpmqyeevggkxowuhkvk/Build/Intermediates.noindex/SR-9508.build/Debug/SR-9508.build/DerivedSources/x86_64 -Xcc -I/Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/SR-9508-djsdvfrplcpmqyeevggkxowuhkvk/Build/Intermediates.noindex/SR-9508.build/Debug/SR-9508.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/nicolasalmoria/Documents/BugReportCompilerCrash4 -module-name SR_9508 -o /Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/SR-9508-djsdvfrplcpmqyeevggkxowuhkvk/Build/Intermediates.noindex/SR-9508.build/Debug/SR-9508.build/Objects-normal/x86_64/main.o -index-store-path /Users/nicolasalmoria/Library/Developer/Xcode/DerivedData/SR-9508-djsdvfrplcpmqyeevggkxowuhkvk/Index/DataStore -index-system-modules
1. While walking into decl declaration 0x7ffb0a8ad148 (at /Users/nicolasalmoria/Documents/BugReportCompilerCrash4/VeniceConnection/main.swift:31:1)
2. While verifying VarDecl 'y' (at /Users/nicolasalmoria/Documents/BugReportCompilerCrash4/VeniceConnection/main.swift:31:5)
0 swift 0x0000000107a03c78 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1 swift 0x0000000107a02ef5 llvm::sys::RunSignalHandlers() + 85
2 swift 0x0000000107a04282 SignalHandler(int) + 258
3 libsystem_platform.dylib 0x00007fff5b7aeb3d _sigtramp + 29
4 libsystem_platform.dylib 0x000000010bc907c7 _sigtramp + 2957909159
5 libsystem_c.dylib 0x00007fff5b66c1c9 abort + 127
6 swift 0x00000001050db8de (anonymous namespace)::Verifier::verifyChecked(swift::ValueDecl*) + 302
7 swift 0x00000001050dbe36 (anonymous namespace)::Verifier::verifyChecked(swift::VarDecl*) + 1286
8 swift 0x00000001050d3e48 (anonymous namespace)::Verifier::walkToDeclPost(swift::Decl*) + 3656
9 swift 0x00000001050dd7ac (anonymous namespace)::Traversal::doIt(swift::Decl*) + 252
10 swift 0x00000001050e16e0 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Pattern*) + 192
11 swift 0x00000001050e1975 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Pattern*) + 853
12 swift 0x00000001050e23ee swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Decl*) + 478
13 swift 0x00000001050dd788 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 216
14 swift 0x00000001050e05c8 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Stmt*) + 472
15 swift 0x00000001050e22fb swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Decl*) + 235
16 swift 0x00000001050dd788 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 216
17 swift 0x00000001050dd69b swift::Decl::walk(swift::ASTWalker&) + 27
18 swift 0x000000010518f5aa swift::SourceFile::walk(swift::ASTWalker&) + 170
19 swift 0x00000001050c9beb swift::verify(swift::SourceFile&) + 59
20 swift 0x0000000104e8ab5f swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 1279
21 swift 0x000000010465d2ac swift::CompilerInstance::parseAndTypeCheckMainFileUpTo(swift::SourceFile::ASTStage_t, swift::PersistentParserState&, swift::DelayedParsingCallbacks*, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>) + 492
22 swift 0x000000010465bc23 swift::CompilerInstance::parseAndCheckTypesUpTo(swift::CompilerInstance::ImplicitImports const&, swift::SourceFile::ASTStage_t) + 435
23 swift 0x000000010465b2e8 swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 616
24 swift 0x0000000103e392c4 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1300
25 swift 0x0000000103e37d42 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2978
26 swift 0x0000000103de9b1e main + 686
27 libdyld.dylib 0x00007fff5b5c3ed9 start + 1
error: Abort trap: 6 |
I just meant that it's a known issue that "typealiases in constrained extensions" don't really work, but you're right that "it works in contexts where it shouldn't" is different from "it doesn't work in contexts where it ought to". |
Huon added code a while ago to check constraints when accessing a type alias as a member, but perhaps there's still some bugs remaining. I'll take a look later. |
Did this get fixed? |
I never got a chance to investigate, unfortunately. However the test case is no longer crashing. I'll add it to validation-tests and close this bug. |
(I also confirmed it was crashing in the 2018-12-08 snapshot but was fixed in 2019-02-28 on the 5.0 branch, so maybe we don't even need to add a regression test if it was a deliberate fix. But lets do it just to be sure) |
Environment
Xcode 10.1, Development Snapshot 2018-12-10
Additional Detail from JIRA
md5: 4bf7516c124c9b0d78534dc5a869c864
Issue Description:
このコードは、Xcodeの10.1と、デフォルトのツールチェーンと罰金をコンパイルしますが、開発スナップショット2018年12月10日でクラッシュ。
クラッシュログがあります
The text was updated successfully, but these errors were encountered: