← All examples

Context stops at a call

The type a value is stored into reaches the arithmetic that makes it, but stops at a call: what g[…] returns says nothing about the arithmetic in its arguments.

context_stops_at_a_call.zg
# The type a value is stored into reaches the arithmetic that makes it, but stops at a call:
# what `g[…]` returns says nothing about the arithmetic in its arguments (2026-09-23).
fn g ['p': bool] -> uint8 { return 0; }
MAIN {
    let 'x': int64 = 0;
    let 'v': uint8 = g[0 > (-1) minus 'x'];       # the (-1) minus 'x' is int64 arithmetic, not uint8
    let 'w': uint32 = 2 shl 3;                # but a bare literal still takes its width from here
    std::print.useful['v', " ", 'w', newln];
}
Output
0 16