Bug
let tmp: Int = some_var creates an alias to some_var rather than a value copy. Subsequent mutation of some_var changes tmp.
Repro
module alias_bug {
meta { purpose: "repro", version: "1.0.0" }
fn main() -> Int {
let mut y: Int = 8
let tmp: Int = y
y = 4
print_int(tmp) // prints 4, expected 8
print_int(y) // prints 4
return 0
}
}
Expected output
Actual output
Notes
- Only affects
let bindings from a plain variable name (e.g. let tmp: Int = y)
- Bindings from expressions work correctly:
let r: Int = x + y is not affected
- Workaround: use an expression:
let tmp: Int = y + 0
- Found during kodo-vericoding-bench development (v008 GCD iterative variant)
- Likely a MIR lowering or codegen issue where Int values are stored as pointers
Bug
let tmp: Int = some_varcreates an alias tosome_varrather than a value copy. Subsequent mutation ofsome_varchangestmp.Repro
Expected output
Actual output
Notes
letbindings from a plain variable name (e.g.let tmp: Int = y)let r: Int = x + yis not affectedlet tmp: Int = y + 0