Skip to content

Compiler crash when using inout argument with variadic generic param #74867

Open
@hamishknight

Description

@hamishknight

This crashes the compiler:

func foo<each T>(_ x: repeat each T) {}
var i = 0
foo(&i)
Unhandled coercion:
(inout_type
  (struct_type decl="Swift.(file).Int"))
(struct_type decl="Swift.(file).Int")
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.      Program arguments: /Users/hamish/src/swift-dev/build/Release/swift-macosx-arm64/bin/swift-frontend -typecheck /Users/hamish/src/swift-test-arena/main.swift -sdk /Users/hamish/src/MacOSX.sdk -debug-diagnostic-names
1.      Swift version 6.0-dev (LLVM 7a0ecf027d00801, Swift 02a8f24406e348f)
2.      Compiling with effective version 5.10
3.      While evaluating request TypeCheckSourceFileRequest(source_file "/Users/hamish/src/swift-test-arena/main.swift")
4.      While type-checking statement at [/Users/hamish/src/swift-test-arena/main.swift:140:1 - line:140:7] RangeText="foo(&i"
5.      While type-checking expression at [/Users/hamish/src/swift-test-arena/main.swift:140:1 - line:140:7] RangeText="foo(&i"
6.      While type-checking-target starting at /Users/hamish/src/swift-test-arena/main.swift:140:1
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           0x000000010a1d0a98 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x000000010a1cede4 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x000000010a1d1120 SignalHandler(int) + 352
3  libsystem_platform.dylib 0x0000000180ce9a24 _sigtramp + 56
4  libsystem_pthread.dylib  0x0000000180cbacc0 pthread_kill + 288
5  libsystem_c.dylib        0x0000000180bcaa50 abort + 180
6  swift-frontend           0x000000010a619bbc (anonymous namespace)::ExprRewriter::coerceToType(swift::Expr*, swift::Type, swift::constraints::ConstraintLocatorBuilder) (.cold.18) + 0
7  swift-frontend           0x00000001059576cc (anonymous namespace)::ExprRewriter::coerceToType(swift::Expr*, swift::Type, swift::constraints::ConstraintLocatorBuilder) + 8252
8  swift-frontend           0x0000000105965b00 (anonymous namespace)::ExprRewriter::coerceCallArguments(swift::ArgumentList*, swift::AnyFunctionType*, swift::ConcreteDeclRef, swift::ApplyExpr*, swift::constraints::ConstraintLocatorBuilder, llvm::ArrayRef<swift::AppliedPropertyWrapper>) + 3852
9  swift-frontend           0x000000010596c9b8 (anonymous namespace)::ExprRewriter::finishApply(swift::ApplyExpr*, swift::Type, swift::constraints::ConstraintLocatorBuilder, swift::constraints::ConstraintLocatorBuilder) + 6176
10 swift-frontend           0x0000000105970c34 (anonymous namespace)::ExprRewriter::visitApplyExpr(swift::ApplyExpr*) + 220
11 swift-frontend           0x0000000105958da0 (anonymous namespace)::ExprWalker::walkToExprPost(swift::Expr*) + 116
12 swift-frontend           0x0000000105eeedb0 (anonymous namespace)::Traversal::doIt(swift::Expr*) + 232
13 swift-frontend           0x0000000105eeecbc swift::Expr::walk(swift::ASTWalker&) + 32
14 swift-frontend           0x0000000105953ca8 (anonymous namespace)::ExprWalker::rewriteTarget(swift::constraints::SyntacticElementTarget) + 656
15 swift-frontend           0x00000001059536ac swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::constraints::SyntacticElementTarget) + 604
16 swift-frontend           0x0000000105b869ac swift::TypeChecker::typeCheckTarget(swift::constraints::SyntacticElementTarget&, swift::optionset::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 388
17 swift-frontend           0x0000000105b867d0 swift::TypeChecker::typeCheckExpression(swift::constraints::SyntacticElementTarget&, swift::optionset::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 184
18 swift-frontend           0x0000000105b866a4 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::constraints::ContextualTypeInfo, swift::optionset::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 92
19 swift-frontend           0x0000000105c52e00 (anonymous namespace)::StmtChecker::typeCheckASTNode(swift::ASTNode&) + 240
20 swift-frontend           0x0000000105c56330 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 144
21 swift-frontend           0x0000000105c54968 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 136
22 swift-frontend           0x0000000105c54a0c swift::TypeChecker::typeCheckTopLevelCodeDecl(swift::TopLevelCodeDecl*) + 80
23 swift-frontend           0x0000000105c90f4c swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const + 200
24 swift-frontend           0x0000000105c928f0 swift::TypeCheckSourceFileRequest::OutputType swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType)::'lambda'()>(swift::TypeCheckSourceFileRequest const&, swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType)::'lambda'()) + 216
25 swift-frontend           0x0000000105c90e5c swift::performTypeChecking(swift::SourceFile&) + 84
26 swift-frontend           0x0000000104bf70bc bool llvm::function_ref<bool (swift::SourceFile&)>::callback_fn<swift::CompilerInstance::performSema()::$_0>(long, swift::SourceFile&) + 16
27 swift-frontend           0x0000000104bf0c28 swift::CompilerInstance::forEachFileToTypeCheck(llvm::function_ref<bool (swift::SourceFile&)>) + 156
28 swift-frontend           0x0000000104bf0b6c swift::CompilerInstance::performSema() + 76
29 swift-frontend           0x00000001049a03ac withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 60
30 swift-frontend           0x0000000104995a6c performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 700
31 swift-frontend           0x0000000104995214 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2288
32 swift-frontend           0x00000001047d26f4 swift::mainEntry(int, char const**) + 3060
33 dyld                     0x0000000180941058 start + 2224
fish: Job 1, './swift -frontend -typecheck ~/…' terminated by signal SIGABRT (Abort)

Metadata

Metadata

Assignees

No one assigned

    Labels

    assertion failureBug → crash: An assertion failurebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.call expressionsFeature → expressions: Call expressionscompilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareexpressionsFeature: expressionsgenericsFeature: generic declarations and typesin-out expressionsFeature → expressions: In-out expressionsparameter packsFeature → generics: Parameter packsswift 6.0type checkerArea → compiler: Semantic analysis

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions