Global Variables
test-global-mutation

Test global mutation:

    check("var x: i64 = 0; fn inc() i64 { x = x + 1; return x; } inc(); inc(); inc()", 3);

Each call to inc() reads x, adds 1, stores it back -- in the global table. After three calls, x is 3.

    check(
        \\var counter: i64 = 0;
        \\fn bump() i64 {
        \\    counter = counter + 1;
        \\    return counter;
        \\}
        \\bump();
        \\bump();
        \\bump();
        \\counter
    , 3);

This is the pattern the self-hosted compiler uses: src_pos, out_pos, and src_len are globals, modified by scanner and emitter functions, visible everywhere.