Global Variables
test-emit-num-globals

Test that emit_num recursion works with globals. This was broken before -- the recursive call would save and restore out_pos, undoing the inner call's writes.

    check(
        \\var out_pos: i64 = 0;
        \\fn emit_byte(b: i64) i64 {
        \\    store8(50000 + out_pos, b);
        \\    out_pos = out_pos + 1;
        \\    return 0;
        \\}
        \\fn emit_num(n: i64) i64 {
        \\    if (n > 9) { emit_num(n / 10); }
        \\    emit_byte(48 + n - n / 10 * 10);
        \\    return 0;
        \\}
        \\emit_num(12345);
        \\out_pos
    , 5);

Five bytes written. emit_num(12345) recurses four levels deep. Each level calls emit_byte which increments out_pos. Because out_pos is a global, the increment persists through all the recursive calls.

With the old (broken) scoping, each call_fn would save out_pos and restore it on return. The inner calls would write bytes, but out_pos would reset to 0 after each return. Total bytes written: 1 (only the last digit). Now it's 5. That's the fix.