Skip to content

Compiler crash on repeat inout each T parameter #74868

Open
@hamishknight

Description

@hamishknight

This crashes the compiler:

func foo<each T>(_ x: repeat inout each T) {}

It should probably be rejected instead.

[cleanup]   %1 = alloc_stack $Pack{repeat each T}, var, name "x" // user: %2
Unhandled transform?
UNREACHABLE executed at /Users/hamish/src/swift-dev/swift/lib/SILGen/SILGenPoly.cpp:682!
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 -emit-sil
1.      Swift version 6.0-dev (LLVM 7a0ecf027d00801, Swift 02a8f24406e348f)
2.      Compiling with effective version 5.10
3.      While evaluating request ASTLoweringRequest(Lowering AST to SIL for module main)
4.      While silgen emitFunction SIL function "@$s4main3fooyyxxQpzRvzlF".
 for 'foo(_:)' (at /Users/hamish/src/swift-test-arena/main.swift:138: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           0x0000000106560a98 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x000000010655ede4 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000106561120 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           0x00000001064d6ea8 llvm::install_out_of_memory_new_handler() + 0
7  swift-frontend           0x00000001013c8f9c (anonymous namespace)::Transform::transform(swift::Lowering::ManagedValue, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::AbstractionPattern, swift::CanType, swift::SILType, swift::Lowering::SGFContext) + 6244
8  swift-frontend           0x00000001013c6f8c swift::Lowering::SILGenFunction::emitOrigToSubstValue(swift::SILLocation, swift::Lowering::ManagedValue, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::SGFContext) + 220
9  swift-frontend           0x00000001013e334c (anonymous namespace)::EmitBBArguments::handleScalar(swift::Lowering::ManagedValue, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::Initialization*, bool) + 624
10 swift-frontend           0x00000001013e2ff8 (anonymous namespace)::ArgumentInitHelper::makeArgument(swift::SILLocation, swift::ParamDecl*) + 1256
11 swift-frontend           0x00000001013e1c50 (anonymous namespace)::ArgumentInitHelper::emitParam(swift::ParamDecl*) + 264
12 swift-frontend           0x00000001013e0d08 swift::Lowering::SILGenFunction::emitBasicProlog(swift::DeclContext*, swift::ParameterList*, swift::ParamDecl*, swift::Type, std::__1::optional<swift::Type>, swift::SourceLoc, unsigned int) + 1532
13 swift-frontend           0x00000001013df518 swift::Lowering::SILGenFunction::emitProlog(swift::DeclContext*, swift::CaptureInfo, swift::ParameterList*, swift::ParamDecl*, swift::Type, std::__1::optional<swift::Type>, swift::SourceLoc) + 272
14 swift-frontend           0x000000010137a654 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 220
15 swift-frontend           0x00000001012ef9b0 swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 6280
16 swift-frontend           0x00000001012f0670 swift::Lowering::SILGenModule::emitOrDelayFunction(swift::SILDeclRef) + 236
17 swift-frontend           0x00000001012ee10c swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 200
18 swift-frontend           0x00000001012f2b28 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 756
19 swift-frontend           0x00000001013e7210 swift::SimpleRequest<swift::ASTLoweringRequest, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>> (swift::ASTLoweringDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::ASTLoweringRequest const&, swift::Evaluator&) + 132
20 swift-frontend           0x00000001012f7f5c swift::ASTLoweringRequest::OutputType swift::Evaluator::getResultUncached<swift::ASTLoweringRequest, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'()>(swift::ASTLoweringRequest const&, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'()) + 324
21 swift-frontend           0x00000001012f31f4 swift::performASTLowering(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions const&, swift::IRGenOptions const*) + 120
22 swift-frontend           0x0000000100d23f74 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 724
23 swift-frontend           0x0000000100d30414 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 164
24 swift-frontend           0x0000000100d25a6c performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 700
25 swift-frontend           0x0000000100d25214 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2288
26 swift-frontend           0x0000000100b626f4 swift::mainEntry(int, char const**) + 3060
27 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.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwaredeclarationsFeature: declarationsfuncFeature → declarations: FunctionsgenericsFeature: generic declarations and typesinoutFeature → types: `inout` typesparameter packsFeature → generics: Parameter packsswift 6.0type checkerArea → compiler: Semantic analysistypesFeature: types

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions