Skip to content

bug: let binding of Int from variable creates alias instead of copy #56

Description

@rfunix

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

8
4

Actual output

4
4

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions