Skip to content

Crash in lower with a choice value: const_id.is_concrete() fails #6862

@danakj

Description

@danakj

Description of the bug:

CHECK failure at toolchain/lower/function_context.cpp:187: const_id.is_concrete(): Missing value: inst4E000330 {kind: AcquireValue, arg0: inst4E00032F, type: type(inst4E000013)} in specific<none> has non-concrete value runtime
choice VehicleType {
   Bike,
   Car,
   Bus
}
fn F() {
  let my_vehicle: VehicleType = VehicleType.Car;
}
Please report issues to https://github.com/carbon-language/carbon-lang/issues and include the crash backtrace.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/carbon-trunk/bin/carbon compile --output=/app/output.s --asm-output <source>
1.	Carbon version: 0.0.0-0.nightly.2026.03.06+97af347
2.	Pending diagnostics:
3.	Filename: <source>
4.	<source>:6:1: Lowering function {}
          fn F() {
          ^~~~~~~~
5.	<source>:7:33: Lowering name_ref
            let my_vehicle: VehicleType = VehicleType.Car;
                                          ^~~~~~~~~~~~~~~
 #0 0x0000568df40a24e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/carbon-trunk/bin/carbon+0x866d4e8)
 #1 0x0000568df409fa74 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/carbon-trunk/bin/carbon+0x866aa74)
 #2 0x0000568df40a2f81 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007f29f1842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f29f18969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007f29f1842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007f29f18287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x0000568def4c5d36 Carbon::Internal::CheckFailImpl(char const*, char const*, int, char const*, llvm::StringRef) (/opt/compiler-explorer/carbon-trunk/bin/carbon+0x3a90d36)
 #8 0x0000568def3beffc void Carbon::Internal::CheckFail<Carbon::TemplateString<5>{"CHECK"}, Carbon::TemplateString<36>{"toolchain/lower/function_context.cpp"}, 187, Carbon::TemplateString<22>{"const_id.is_concrete()"}, Carbon::TemplateString<56>{"Missing value: {0} {1} in {2} has non-concrete value {3}"}, Carbon::SemIR::InstId&, Carbon::SemIR::Inst, Carbon::SemIR::SpecificId&, Carbon::SemIR::ConstantId&>(Carbon::SemIR::InstId&, Carbon::SemIR::Inst&&, Carbon::SemIR::SpecificId&, Carbon::SemIR::ConstantId&) (/opt/compiler-explorer/carbon-trunk/bin/carbon+0x3989ffc)
 #9 0x0000568def3beeda Carbon::Lower::FunctionContext::GetValue(Carbon::SemIR::InstId) (/opt/compiler-explorer/carbon-trunk/bin/carbon+0x3989eda)
#10 0x0000568def3cb024 Carbon::Lower::HandleInst(Carbon::Lower::FunctionContext&, Carbon::SemIR::InstId, Carbon::SemIR::NameRef) (/opt/compiler-explorer/carbon-trunk/bin/carbon+0x3996024)
#11 0x0000568def3bb3b4 Carbon::Lower::FunctionContext::LowerInst(Carbon::SemIR::InstId) (/opt/compiler-explorer/carbon-trunk/bin/carbon+0x39863b4)
#12 0x0000568def3ba871 Carbon::Lower::FunctionContext::LowerBlockContents(Carbon::SemIR::InstBlockId) (/opt/compiler-explorer/carbon-trunk/bin/carbon+0x3985871)
#13 0x0000568def3a9209 Carbon::Lower::FileContext::BuildFunctionBody(Carbon::SemIR::FunctionId, Carbon::SemIR::SpecificId, Carbon::SemIR::Function const&, Carbon::Lower::FileContext&, Carbon::SemIR::Function const&) (/opt/compiler-explorer/carbon-trunk/bin/carbon+0x3974209)
#14 0x0000568def3a7db8 Carbon::Lower::FileContext::LowerDefinitions() (/opt/compiler-explorer/carbon-trunk/bin/carbon+0x3972db8)
#15 0x0000568def3a3def Carbon::Lower::LowerToLLVM(llvm::LLVMContext&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, Carbon::FixedSizeValueStore<Carbon::SemIR::CheckIRId, llvm::function_ref<Carbon::Parse::TreeAndSubtrees const& ()>, Carbon::Untagged> const&, Carbon::SemIR::File const&, int, Carbon::Lower::LowerToLLVMOptions const&) (/opt/compiler-explorer/carbon-trunk/bin/carbon+0x396edef)
#16 0x0000568dee5318b9 void llvm::function_ref<void ()>::callback_fn<Carbon::(anonymous namespace)::CompilationUnit::RunLower()::$_0>(long) compile_subcommand.cpp:0:0
#17 0x0000568dee52df1e Carbon::(anonymous namespace)::CompilationUnit::LogCall(llvm::StringLiteral, llvm::StringLiteral, llvm::function_ref<void ()>) compile_subcommand.cpp:0:0
#18 0x0000568dee52aff0 Carbon::CompileSubcommand::Run(Carbon::DriverEnv&) (/opt/compiler-explorer/carbon-trunk/bin/carbon+0x2af5ff0)
#19 0x0000568dee51ff54 Carbon::Driver::RunCommand(llvm::ArrayRef<llvm::StringRef>) (/opt/compiler-explorer/carbon-trunk/bin/carbon+0x2aeaf54)
#20 0x0000568dee4f6ffb Carbon::Main(int, char**) busybox_main.cpp:0:0
#21 0x0000568dee4f47d4 main (/opt/compiler-explorer/carbon-trunk/bin/carbon+0x2abf7d4)
#22 0x00007f29f1829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#23 0x00007f29f1829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#24 0x0000568dee4f4725 _start (/opt/compiler-explorer/carbon-trunk/bin/carbon+0x2abf725)
CHECK failure at toolchain/lower/function_context.cpp:187: const_id.is_concrete(): Missing value: inst4E000330 {kind: AcquireValue, arg0: inst4E00032F, type: type(inst4E000013)} in specific<none> has non-concrete value runtime
Program terminated with signal: SIGSEGV

What did you do, or what's a simple way to reproduce the bug?

No response

What did you expect to happen?

No response

What actually happened?

No response

Any other information, logs, or outputs that you want to share?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions