Skip to content

[SR-488] Crash when emitting store into a generic member, from initializer in an extension #43105

Closed
@jadengeller

Description

@jadengeller
Previous ID SR-488
Radar rdar://problem/21473547
Original Reporter @JadenGeller
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash
Assignee @slavapestov
Priority Medium

md5: 4cc3ecb039495bae0b76cbb3c7e41251

is duplicated by:

  • SR-493 Compiler crashes when Implementing ArrayLitteralConvertible In a generic struct

relates to:

  • SR-493 Compiler crashes when Implementing ArrayLitteralConvertible In a generic struct

Issue Description:

When a generic type Blah<Value> contains a generic property with a default value, such as var backing: Value? = nil, the compiler will crash if an initializer is placed in an extension (even in the same file).

struct Blah<Value> {
    var backing: Value?
}

extension Blah {
    init(test: Int) {
        // crash when emitting implicit store "backing = nil"
    }
}

The stack trace is:

#&#8203;4  llvm_unreachable("unexpected storage type that differs from type-of-rvalue");
#&#8203;5  emitStoreOfSemanticRValue(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::SILValue, swift::SILValue, swift::Lowering::TypeLowering const&, swift::IsInitialization_t)
#&#8203;6  swift::Lowering::SILGenFunction::emitSemanticStore(swift::SILLocation, swift::SILValue, swift::SILValue, swift::Lowering::TypeLowering const&, swift::IsInitialization_t)
#&#8203;7  swift::Lowering::ManagedValue::assignInto(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::SILValue)
#&#8203;8  assignRecursive(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::CanType, llvm::ArrayRef<swift::Lowering::ManagedValue>&, swift::SILValue)
#&#8203;9  swift::Lowering::RValue::assignInto(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::SILValue) &&
#&#8203;10 swift::Lowering::SILGenFunction::emitAssignToLValue(swift::SILLocation, swift::Lowering::RValue&&, swift::Lowering::LValue&&)
#&#8203;11 emitMemberInit(swift::Lowering::SILGenFunction&, swift::VarDecl*, swift::Pattern*, swift::Lowering::RValue&&)
#&#8203;12 emitMemberInit(swift::Lowering::SILGenFunction&, swift::VarDecl*, swift::Pattern*, swift::Lowering::RValue&&)
#&#8203;13 swift::Lowering::SILGenFunction::emitMemberInitializers(swift::VarDecl*, swift::NominalTypeDecl*)
#&#8203;14 swift::Lowering::SILGenFunction::emitValueConstructor(swift::ConstructorDecl*)
#&#8203;15 swift::Lowering::SILGenModule::emitConstructor(swift::ConstructorDecl*)::$_4::operator()(swift::SILFunction*) const
#&#8203;16 void emitOrDelayFunction<swift::Lowering::SILGenModule::emitConstructor(swift::ConstructorDecl*)::$_4>(swift::Lowering::SILGenModule&, swift::SILDeclRef, swift::Lowering::SILGenModule::emitConstructor(swift::ConstructorDecl*)::$_4&&)
#&#8203;17 swift::Lowering::SILGenModule::emitConstructor(swift::ConstructorDecl*)
#&#8203;18 SILGenExtension::visitConstructorDecl(swift::ConstructorDecl*)

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of software

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions