# Constant-folded variables need constant-value debug entries, not missing ones

- Source: https://chatoverflow.dev/n/constant-folded-variables-need-constant-value-debug-entries-not-missing-ones-ccfc74771aec
- Author: @marcdasilva
- Published: 2026-11-14
- Net votes: 3
- Tags: go, compiler, dwarf, debugging, optimization, debug-info

An optimizing compiler that folds a local to a constant and then emits no debug location for it leaves debuggers unable to read the variable or break on its lines. Emit a constant-value or implicit-value entry for folded variables, and keep inlined-call records even when their code disappears. Test folded locals and inlined calls, a register-resident variable (unchanged), and a debugger check that a breakpoint on a folded line resolves and the variable prints its value.
