Skip to content

Initializing non-existent property with type with parameter pack causes ICE #66395

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

Closed
keith opened this issue Jun 6, 2023 · 1 comment · Fixed by #66632
Closed

Initializing non-existent property with type with parameter pack causes ICE #66395

keith opened this issue Jun 6, 2023 · 1 comment · Fixed by #66632
Assignees
Labels
assertion failure Bug → crash: An assertion failure bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself crash Bug: A crash, i.e., an abnormal termination of software generics Feature: generic declarations and types parameter packs Feature → generics: Parameter packs swift 5.9 type checker Area → compiler: Semantic analysis type declarations Feature → declarations: Type declarations

Comments

@keith
Copy link
Member

keith commented Jun 6, 2023

With this code:

struct Thing<each T> {
    init() {
        self.abc = 1
    }
}

The compiler crashes:

error: compile command failed due to signal 6 (use -v to see invocation)
Assertion failed: (isa<To>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file Casting.h, line 578.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.      Program arguments: /Users/ksmiley/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2023-06-05-a.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file /tmp/foo.swift -target arm64-apple-macosx13.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode-15.0.0-beta1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -color-diagnostics -new-driver-path /Users/ksmiley/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2023-06-05-a.xctoolchain/usr/bin/swift-driver -disable-availability-checking -empty-abi-descriptor -plugin-path /Users/ksmiley/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2023-06-05-a.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Users/ksmiley/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2023-06-05-a.xctoolchain/usr/local/lib/swift/host/plugins -resource-dir /Users/ksmiley/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2023-06-05-a.xctoolchain/usr/lib/swift -module-name foo -target-sdk-version 14.0 -target-sdk-name macosx14.0 -o /var/folders/gj/wf3swl0x215b2sq1qy84kzkm0000gn/T/TemporaryDirectory.tJyZTc/foo-1.o
1.      Apple Swift version 5.9-dev (LLVM 4a3b38183d7bb09, Swift 44a40979e52be8e)
2.      Compiling with the current language version
3.      While evaluating request TypeCheckSourceFileRequest(source_file "/tmp/foo.swift")
4.      While evaluating request TypeCheckFunctionBodyRequest(foo.(file).Thing.init()@/tmp/foo.swift:3:5)
5.      While type-checking statement at [/tmp/foo.swift:3:12 - line:5:4] RangeText="{
        self.abc = 1
   "
6.      While type-checking expression at [/tmp/foo.swift:4:9 - line:4:20] RangeText="self.abc = "
7.      While type-checking-target starting at /tmp/foo.swift:4:9
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x0000000104f41f30 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000104f412d4 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000104f42570 SignalHandler(int) + 304
3  libsystem_platform.dylib 0x00000001a84eaa24 _sigtramp + 56
4  libsystem_pthread.dylib  0x00000001a84bbc28 pthread_kill + 288
5  libsystem_c.dylib        0x00000001a83c9ae8 abort + 180
6  libsystem_c.dylib        0x00000001a83c8e44 err + 0
7  swift-frontend           0x0000000105425b54 swift::PackType::getExpandedGenericArgs(swift::ArrayRefView<swift::Type, swift::GenericTypeParamType*, swift::GenericTypeParamType* swift::staticCastHelper<swift::GenericTypeParamType>(swift::Type const&), true>, llvm::ArrayRef<swift::Type>) (.cold.5) + 0
8  swift-frontend           0x00000001017faf34 swift::PackType::getExpandedGenericArgs(swift::ArrayRefView<swift::Type, swift::GenericTypeParamType*, swift::GenericTypeParamType* swift::staticCastHelper<swift::GenericTypeParamType>(swift::Type const&), true>, llvm::ArrayRef<swift::Type>) + 376
9  swift-frontend           0x00000001017fad54 swift::BoundGenericType::getExpandedGenericArgs() + 248
10 swift-frontend           0x00000001015a7e98 (anonymous namespace)::TypePrinter::visitBoundGenericType(swift::BoundGenericType*) + 1848
11 swift-frontend           0x000000010158b278 swift::Type::print(swift::ASTPrinter&, swift::PrintOptions const&) const + 76
12 swift-frontend           0x000000010158c5a0 swift::TypeBase::getString(swift::PrintOptions const&) const + 188
13 swift-frontend           0x000000010171615c formatDiagnosticArgument(llvm::StringRef, llvm::StringRef, llvm::ArrayRef<swift::DiagnosticArgument>, unsigned int, swift::DiagnosticFormatOptions, llvm::raw_ostream&) + 5704
14 swift-frontend           0x00000001017149c4 swift::DiagnosticEngine::formatDiagnosticText(llvm::raw_ostream&, llvm::StringRef, llvm::ArrayRef<swift::DiagnosticArgument>, swift::DiagnosticFormatOptions) + 844
15 swift-frontend           0x0000000100443254 swift::PrintingDiagnosticConsumer::printDiagnostic(swift::SourceManager&, swift::DiagnosticInfo const&) + 756
16 swift-frontend           0x0000000100442078 swift::PrintingDiagnosticConsumer::handleDiagnostic(swift::SourceManager&, swift::DiagnosticInfo const&) + 1212
17 swift-frontend           0x0000000101716de8 swift::DiagnosticEngine::emitDiagnostic(swift::Diagnostic const&) + 884
18 swift-frontend           0x0000000101716a20 swift::DiagnosticEngine::handleDiagnostic(swift::Diagnostic&&) + 176
19 swift-frontend           0x000000010171441c swift::InFlightDiagnostic::flush() + 56
20 swift-frontend           0x000000010114361c swift::constraints::MissingMemberFailure::diagnoseAsError()::$_21::operator()(swift::Type) const + 604
21 swift-frontend           0x00000001011427e4 swift::constraints::MissingMemberFailure::diagnoseAsError() + 4136
22 swift-frontend           0x0000000101121ca8 swift::constraints::DefineMemberBasedOnUse::diagnose(swift::constraints::Solution const&, bool) const + 108
23 swift-frontend           0x000000010105e730 swift::constraints::ConstraintSystem::applySolutionFixes(swift::constraints::Solution const&) + 1576
24 swift-frontend           0x000000010105ee6c swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::constraints::SyntacticElementTarget) + 92
25 swift-frontend           0x000000010126a650 swift::TypeChecker::typeCheckTarget(swift::constraints::SyntacticElementTarget&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 396
26 swift-frontend           0x000000010126a46c swift::TypeChecker::typeCheckExpression(swift::constraints::SyntacticElementTarget&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 184
27 swift-frontend           0x000000010126a32c swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::constraints::ContextualTypeInfo, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 84
28 swift-frontend           0x0000000101342a18 (anonymous namespace)::StmtChecker::typeCheckASTNode(swift::ASTNode&) + 236
29 swift-frontend           0x0000000101345854 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 328
30 swift-frontend           0x0000000101343f10 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 136
31 swift-frontend           0x000000010134359c swift::TypeCheckFunctionBodyRequest::evaluate(swift::Evaluator&, swift::AbstractFunctionDecl*) const + 1028
32 swift-frontend           0x00000001016e62c0 llvm::Expected<swift::TypeCheckFunctionBodyRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckFunctionBodyRequest>(swift::TypeCheckFunctionBodyRequest const&) + 392
33 swift-frontend           0x00000001016e605c llvm::Expected<swift::TypeCheckFunctionBodyRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckFunctionBodyRequest, (void*)0>(swift::TypeCheckFunctionBodyRequest const&) + 120
34 swift-frontend           0x00000001016347d0 swift::TypeCheckFunctionBodyRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckFunctionBodyRequest>(swift::Evaluator&, swift::TypeCheckFunctionBodyRequest, swift::TypeCheckFunctionBodyRequest::OutputType) + 52
35 swift-frontend           0x000000010137b678 swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const + 312
36 swift-frontend           0x000000010137d958 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest>(swift::TypeCheckSourceFileRequest const&) + 388
37 swift-frontend           0x000000010137d6e8 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckSourceFileRequest, (void*)0>(swift::TypeCheckSourceFileRequest const&) + 84
38 swift-frontend           0x000000010137b458 swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType) + 44
39 swift-frontend           0x00000001004273a4 bool llvm::function_ref<bool (swift::SourceFile&)>::callback_fn<swift::CompilerInstance::performSema()::$_9>(long, swift::SourceFile&) + 16
40 swift-frontend           0x00000001004218d0 swift::CompilerInstance::forEachFileToTypeCheck(llvm::function_ref<bool (swift::SourceFile&)>) + 76
41 swift-frontend           0x0000000100421864 swift::CompilerInstance::performSema() + 76
42 swift-frontend           0x0000000100294508 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 60
43 swift-frontend           0x0000000100287e5c performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 724
44 swift-frontend           0x0000000100286df0 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2456
45 swift-frontend           0x00000001000d1524 swift::mainEntry(int, char const**) + 2144
46 dyld                     0x00000001a8163f28 start + 2236

Steps to reproduce

xcrun --toolchain org.swift.59202306051a swiftc /tmp/foo.swift -Xfrontend -disable-availability-checking

Environment

  • 6/5/23 main snapshot
@keith keith added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Jun 6, 2023
@hborla hborla self-assigned this Jun 14, 2023
@hborla hborla added crash Bug: A crash, i.e., an abnormal termination of software parameter packs Feature → generics: Parameter packs and removed triage needed This issue needs more specific labels labels Jun 14, 2023
@vanvoorden
Copy link
Contributor

@hborla I saw a similar error in #71258.

@AnthonyLatsis AnthonyLatsis added compiler The Swift compiler itself type checker Area → compiler: Semantic analysis generics Feature: generic declarations and types swift 5.9 assertion failure Bug → crash: An assertion failure type declarations Feature → declarations: Type declarations labels Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assertion failure Bug → crash: An assertion failure bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself crash Bug: A crash, i.e., an abnormal termination of software generics Feature: generic declarations and types parameter packs Feature → generics: Parameter packs swift 5.9 type checker Area → compiler: Semantic analysis type declarations Feature → declarations: Type declarations
Projects
None yet
4 participants