Skip to content

Crash on unnamed property wrapped function parameter #76308

Open
@AnthonyLatsis

Description

@AnthonyLatsis

Description

No response

Reproduction

@propertyWrapper
struct W {
  let wrappedValue: Int
}
func test(@W _: Int) {}
test(5)

Stack dump

Assertion failed: (!getDeclContext()->isLocalContext() && "not a global variable!"), function isLazilyInitializedGlobal, file Decl.cpp, line 7584.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: bin/swift-frontend -debug-diagnostic-names /Users/mac/Desktop/test.swift -emit-ir
1.	Swift version 6.1-dev (LLVM fe0f467028c23cf, Swift 614e8aa79a84486)
2.	Compiling with effective version 5.10
3.	While evaluating request ASTLoweringRequest(Lowering AST to SIL for module test)
4.	While silgen emitFunction SIL function "@$s4testAAyySiF".
 for 'test(_:)' (at /Users/mac/Desktop/test.swift:306: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           0x0000000110703f78 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 40
1  swift-frontend           0x00000001107023c5 llvm::sys::RunSignalHandlers() + 85
2  swift-frontend           0x00000001107045ce SignalHandler(int) + 270
3  libsystem_platform.dylib 0x00007ff80d870fdd _sigtramp + 29
4  libsystem_platform.dylib 0x01017fc2e602c000 _sigtramp + 72338840718389312
5  libsystem_c.dylib        0x00007ff80d767a79 abort + 126
6  libsystem_c.dylib        0x00007ff80d766d68 err + 0
7  swift-frontend           0x000000010b557bec swift::VarDecl::isLazilyInitializedGlobal() const + 108
8  swift-frontend           0x0000000108d505f4 swift::Lowering::SILGenFunction::emitGlobalVariableRef(swift::SILLocation, swift::VarDecl*, std::__1::optional<swift::ActorIsolation>) + 148
9  swift-frontend           0x0000000108da0ba5 swift::Lowering::LValue::addNonMemberVarComponent(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::VarDecl*, swift::SubstitutionMap, swift::Lowering::LValueOptions, swift::Lowering::SGFAccessKind, swift::AccessStrategy, swift::CanType, std::__1::optional<swift::ActorIsolation>)::NonMemberVarAccessEmitter::emitUsingStorage(swift::Lowering::LValueTypeData) + 213
10 swift-frontend           0x0000000108d81eee (anonymous namespace)::AccessEmitter<swift::Lowering::LValue::addNonMemberVarComponent(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::VarDecl*, swift::SubstitutionMap, swift::Lowering::LValueOptions, swift::Lowering::SGFAccessKind, swift::AccessStrategy, swift::CanType, std::__1::optional<swift::ActorIsolation>)::NonMemberVarAccessEmitter, swift::VarDecl>::emitUsingStrategy(swift::AccessStrategy) + 286
11 swift-frontend           0x0000000108d81d0c swift::Lowering::LValue::addNonMemberVarComponent(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::VarDecl*, swift::SubstitutionMap, swift::Lowering::LValueOptions, swift::Lowering::SGFAccessKind, swift::AccessStrategy, swift::CanType, std::__1::optional<swift::ActorIsolation>) + 332
12 swift-frontend           0x0000000108d83e3f emitLValueForNonMemberVarDecl(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::ConcreteDeclRef, swift::CanType, swift::Lowering::SGFAccessKind, swift::Lowering::LValueOptions, swift::AccessSemantics, std::__1::optional<swift::ActorIsolation>) + 559
13 swift-frontend           0x0000000108d83214 swift::Lowering::SILGenFunction::emitRValueForNonMemberVarDecl(swift::SILLocation, swift::ConcreteDeclRef, swift::CanType, swift::AccessSemantics, swift::Lowering::SGFContext) + 3220
14 swift-frontend           0x0000000108cdfa4c swift::Lowering::SILGenFunction::emitRValueForDecl(swift::SILLocation, swift::ConcreteDeclRef, swift::Type, swift::AccessSemantics, swift::Lowering::SGFContext) + 588
15 swift-frontend           0x0000000108cfe527 (anonymous namespace)::RValueEmitter::visitDeclRefExpr(swift::DeclRefExpr*, swift::Lowering::SGFContext) + 183
16 swift-frontend           0x0000000108cee165 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 645
17 swift-frontend           0x0000000108cde631 swift::Lowering::SILGenFunction::emitRValue(swift::Expr*, swift::Lowering::SGFContext) + 209
18 swift-frontend           0x0000000108ce3750 swift::Lowering::SILGenFunction::emitRValueAsSingleValue(swift::Expr*, swift::Lowering::SGFContext) + 80
19 swift-frontend           0x0000000108c0b804 (anonymous namespace)::ArgEmitter::emitDirect(swift::Lowering::ArgumentSource&&, swift::SILType, swift::Lowering::AbstractionPattern, swift::SILParameterInfo, std::__1::optional<swift::AnyFunctionType::Param>) + 884
20 swift-frontend           0x0000000108c087c9 (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern, std::__1::optional<swift::AnyFunctionType::Param>) + 2329
21 swift-frontend           0x0000000108bf2789 (anonymous namespace)::ArgEmitter::emitSingleArg(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern, std::__1::optional<swift::AnyFunctionType::Param>) + 473
22 swift-frontend           0x0000000108c01ebf (anonymous namespace)::ArgEmitter::emitPreparedArgs(swift::Lowering::PreparedArguments&&, swift::Lowering::AbstractionPattern) + 447
23 swift-frontend           0x0000000108c2e491 (anonymous namespace)::CallSite::emit(swift::Lowering::SILGenFunction&, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::SILFunctionType>, (anonymous namespace)::ParamLowering&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, llvm::SmallVectorImpl<(anonymous namespace)::DelayedArgument>&, swift::ForeignInfo const&) && + 481
24 swift-frontend           0x0000000108c2d3a6 (anonymous namespace)::CallEmission::emitArgumentsForNormalApply(swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::SILFunctionType>, swift::ForeignInfo const&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, std::__1::optional<swift::SILLocation>&) + 1574
25 swift-frontend           0x0000000108c2c684 (anonymous namespace)::CallEmission::applyNormalCall(swift::Lowering::SGFContext) + 1108
26 swift-frontend           0x0000000108c2ae7b (anonymous namespace)::CallEmission::applyFirstLevelCallee(swift::Lowering::SGFContext) + 219
27 swift-frontend           0x0000000108bf59ae (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 94
28 swift-frontend           0x0000000108bf5332 swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 130
29 swift-frontend           0x0000000108d1ba79 (anonymous namespace)::RValueEmitter::visitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 73
30 swift-frontend           0x0000000108d06896 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visitCallExpr(swift::CallExpr*, swift::Lowering::SGFContext) + 70
31 swift-frontend           0x0000000108ceeb65 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 3205
32 swift-frontend           0x0000000108cde631 swift::Lowering::SILGenFunction::emitRValue(swift::Expr*, swift::Lowering::SGFContext) + 209
33 swift-frontend           0x0000000108cde435 swift::Lowering::SILGenFunction::emitExprInto(swift::Expr*, swift::Lowering::Initialization*, std::__1::optional<swift::SILLocation>) + 357
34 swift-frontend           0x0000000108ca8d6f swift::Lowering::SILGenFunction::emitPatternBinding(swift::PatternBindingDecl*, unsigned int, bool)::$_0::operator()(swift::Expr*, swift::VarDecl*, bool, std::__1::unique_ptr<swift::Lowering::Initialization, std::__1::default_delete<swift::Lowering::Initialization>>&) const + 671
35 swift-frontend           0x0000000108ca8751 swift::Lowering::SILGenFunction::emitPatternBinding(swift::PatternBindingDecl*, unsigned int, bool) + 1489
36 swift-frontend           0x0000000108ca8e46 swift::Lowering::SILGenFunction::visitPatternBindingDecl(swift::PatternBindingDecl*, bool) + 150
37 swift-frontend           0x0000000108cbe392 swift::ASTVisitor<swift::Lowering::SILGenFunction, void, void, void, void, void, void>::visit(swift::Decl*) + 1522
38 swift-frontend           0x0000000108e5655e (anonymous namespace)::StmtEmitter::visitBraceStmt(swift::BraceStmt*) + 382
39 swift-frontend           0x0000000108e508a1 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 81
40 swift-frontend           0x0000000108e5081a swift::Lowering::SILGenFunction::emitStmt(swift::Stmt*) + 42
41 swift-frontend           0x0000000108d3c0fc swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 956
42 swift-frontend           0x0000000108bbd5a0 swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 4512
43 swift-frontend           0x0000000108bc0db4 swift::Lowering::SILGenModule::emitOrDelayFunction(swift::SILDeclRef) + 564
44 swift-frontend           0x0000000108bbc3d2 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 450
45 swift-frontend           0x0000000108bbc1fd swift::Lowering::SILGenModule::visitFuncDecl(swift::FuncDecl*) + 29
46 swift-frontend           0x0000000108bbbec4 swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 996
47 swift-frontend           0x0000000108bbbad0 swift::Lowering::SILGenModule::visit(swift::Decl*) + 64
48 swift-frontend           0x0000000108bc6094 (anonymous namespace)::SILGenModuleRAII::emitSourceFile(swift::SourceFile*) + 340
49 swift-frontend           0x0000000108bc5c3f swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 879
50 swift-frontend           0x0000000108e4f9ee std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>> swift::SimpleRequest<swift::ASTLoweringRequest, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>> (swift::ASTLoweringDescriptor), (swift::RequestFlags)17>::callDerived<0ul>(swift::Evaluator&, std::__1::integer_sequence<unsigned long, 0ul>) const + 142
51 swift-frontend           0x0000000108e4f908 swift::SimpleRequest<swift::ASTLoweringRequest, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>> (swift::ASTLoweringDescriptor), (swift::RequestFlags)17>::evaluateRequest(swift::ASTLoweringRequest const&, swift::Evaluator&) + 40
52 swift-frontend           0x0000000108be3498 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'()) + 264
53 swift-frontend           0x0000000108be3378 swift::ASTLoweringRequest::OutputType swift::Evaluator::operator()<swift::ASTLoweringRequest, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'(), (void*)0>(swift::ASTLoweringRequest const&, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'()) + 40
54 swift-frontend           0x0000000108bc6854 swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest) + 36
55 swift-frontend           0x0000000108bc6770 swift::performASTLowering(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions const&, swift::IRGenOptions const*) + 256
56 swift-frontend           0x0000000107da277b swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 283
57 swift-frontend           0x0000000107dc8203 performAction(swift::CompilerInstance&, int&, swift::FrontendObserver*)::$_27::operator()(swift::CompilerInstance&) const + 147
58 swift-frontend           0x0000000107dc815d bool llvm::function_ref<bool (swift::CompilerInstance&)>::callback_fn<performAction(swift::CompilerInstance&, int&, swift::FrontendObserver*)::$_27>(long, swift::CompilerInstance&) + 29
59 swift-frontend           0x0000000107dc7521 llvm::function_ref<bool (swift::CompilerInstance&)>::operator()(swift::CompilerInstance&) const + 33
60 swift-frontend           0x0000000107dc6518 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 392
61 swift-frontend           0x0000000107dbe6b5 performAction(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1349
62 swift-frontend           0x0000000107da5146 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 262
63 swift-frontend           0x0000000107da4427 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2247
64 swift-frontend           0x0000000107a4663a run_driver(llvm::StringRef, llvm::ArrayRef<char const*>, llvm::ArrayRef<char const*>) + 2410
65 swift-frontend           0x0000000107a45275 swift::mainEntry(int, char const**) + 1557
66 swift-frontend           0x0000000107a44942 main + 34
67 dyld                     0x00007ff80d4b6366 start + 1942
Abort trap: 6

Expected behavior

Successful compilation or error.

Environment

Swift version 6.1-dev (Swift 614e8aa)

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    SILGenArea → compiler: The SIL generation stagebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwarefunction parametersFeature → declarations: function parametersproperty wrappersFeature: property wrappersswift 6.1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions