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-9687] Compiler crash with "expression has no type" with extensions on type aliases #52129

Closed
ktoso opened this issue Jan 17, 2019 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@ktoso
Copy link
Member

ktoso commented Jan 17, 2019

Previous ID SR-9687
Radar None
Original Reporter @ktoso
Type Bug
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 7c13f4b8b11ad998b735349fcdc30e3d

duplicates:

  • SR-9671 compiler crash: expression has no type / (declref_expr type='' decl=Logging.(file). extension.init(stringLiteral:)

Issue Description:

This is similar to the just opened https://bugs.swift.org/browse/SR-9686 issue however that one causes compilation errors, and this one is about a compiler crash, which looks like this:

master u+1!swift-server-logging-api-proposal $> swift test
expression has no type
(declref_expr type='<null>' decl=Logging.(file). extension.init(stringLiteral:).self@/Users/ktoso/code/swift-server-logging-api-proposal/Sources/Logging/Logging.swift:294:12 function_ref=unapplied)Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-5.0-DEVELOPMENT-SNAPSHOT-2019-01-16-a.xctoolchain/usr/bin/swift -frontend -c /Users/ktoso/code/swift-server-logging-api-proposal/Sources/Logging/Locks.swift -primary-file /Users/ktoso/code/swift-server-logging-api-proposal/Sources/Logging/Logging.swift -emit-module-path /Users/ktoso/code/swift-server-logging-api-proposal/.build/x86_64-apple-macosx/debug/Logging.build/Logging~partial.swiftmodule -emit-module-doc-path /Users/ktoso/code/swift-server-logging-api-proposal/.build/x86_64-apple-macosx/debug/Logging.build/Logging~partial.swiftdoc -emit-dependencies-path /Users/ktoso/code/swift-server-logging-api-proposal/.build/x86_64-apple-macosx/debug/Logging.build/Logging.d -emit-reference-dependencies-path /Users/ktoso/code/swift-server-logging-api-proposal/.build/x86_64-apple-macosx/debug/Logging.build/Logging.swiftdeps -target x86_64-apple-macosx10.10 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I /Users/ktoso/code/swift-server-logging-api-proposal/.build/x86_64-apple-macosx/debug -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -enable-testing -g -module-cache-path /Users/ktoso/code/swift-server-logging-api-proposal/.build/x86_64-apple-macosx/debug/ModuleCache -swift-version 4.2 -Onone -D SWIFT_PACKAGE -D DEBUG -color-diagnostics -parse-as-library -module-name Logging -o /Users/ktoso/code/swift-server-logging-api-proposal/.build/x86_64-apple-macosx/debug/Logging.build/Logging.swift.o -index-store-path /Users/ktoso/code/swift-server-logging-api-proposal/.build/x86_64-apple-macosx/debug/index/store -index-system-modules
1.  While walking into decl extension of Logging.Metadata.Value (at /Users/ktoso/code/swift-server-logging-api-proposal/Sources/Logging/Logging.swift:291:1)
2.  While walking into body of 'init(stringLiteral:)' (at /Users/ktoso/code/swift-server-logging-api-proposal/Sources/Logging/Logging.swift:294:12)
0  swift                    0x0000000106746848 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x0000000106745ac5 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x0000000106746e52 SignalHandler(int) + 258
3  libsystem_platform.dylib 0x00007fff61402b3d _sigtramp + 29
4  swift                    0x0000000107596008 (anonymous namespace)::DarwinX86AsmBackend::getCompactUnwindRegNum(unsigned int) const::CU64BitRegs + 237330
5  libsystem_c.dylib        0x00007fff612c01c9 abort + 127
6  swift                    0x0000000103e00acc (anonymous namespace)::Verifier::walkToExprPost(swift::Expr*) + 27340
7  swift                    0x0000000103e0e8c6 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 6742
8  swift                    0x0000000103e0fbc7 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Stmt*) + 359
9  swift                    0x0000000103e12b7b (anonymous namespace)::Traversal::visitAbstractFunctionDecl(swift::AbstractFunctionDecl*) + 683
10 swift                    0x0000000103e0cdf8 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 216
11 swift                    0x0000000103e11e96 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Decl*) + 1558
12 swift                    0x0000000103e0cdf8 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 216
13 swift                    0x0000000103e0cd0b swift::Decl::walk(swift::ASTWalker&) + 27
14 swift                    0x0000000103ec3eba swift::SourceFile::walk(swift::ASTWalker&) + 170
ourceFile&) + 59
16 swift                    0x0000000103bba63a swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 1386
17 swift                    0x0000000103384a15 swift::CompilerInstance::parseAndCheckTypesUpTo(swift::CompilerInstance::ImplicitImports const&, swift::SourceFile::ASTStage_t) + 629
18 swift                    0x0000000103384008 swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 616
19 swift                    0x0000000102b5f0fd performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1309
20 swift                    0x0000000102b5db4d swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3021
21 swift                    0x0000000102b0fa6e main + 686
22 libdyld.dylib            0x00007fff61217ed9 start + 1
<unknown>:0: error: unable to execute command: Abort trap: 6
<unknown>:0: error: compile command failed due to signal 6 (use -v to see invocation)

Which happens on 5.0-DEVELOPMENT-SNAPSHOT-2019-01-16-a on a fresh checkout of the SSWG proposal for Logging API: https://github.com/weissi/swift-server-logging-api-proposal

Specifically this file: https://github.com/weissi/swift-server-logging-api-proposal/blob/ba9eac90551949f390af0bf8b2866f755460efe4/Sources/Logging/Logging.swift

The problem seems to, same as SR-9686 appear only on Swift 5 (4.2 works well), and seems to be about extensions on type aliases.

To reproduce clone the https://github.com/ktoso/swift-server-logging-api-proposal/tree/boom-repro on the branch boom-repro (which is same as current HEAD of the proposal, but removes the issues that cause https://bugs.swift.org/browse/SR-9686 on line 142).

The compiler will crash with the error shown above.

Workaround:

Replacing all instances of extension Logging.Metadata.Value with extension Logging.MetadataValue makes the thing compile and work correctly.

// You may need to also remove the public init<T>(stringInterpolationSegment expr: T) {}, though that's fine, and was added a bit too eagerly in there perhaps).

@ktoso
Copy link
Member Author

ktoso commented Jan 17, 2019

Ah, cool – seems Johannes reported the same already 🙂 Thanks for closing as duplicate.

@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

1 participant