Skip to content

V0104: loop changes context state

A loop body must leave every outer context in the state it found it. To grow a context in a loop, consume and re-assign it: c = c ++ "step".

model m = "x" { layers: 1, kv_heads: 1, head_dim: 8 }
fn main() {
let c = open m
for i in 0..3 { drop c }
}
error[V0104]: loop body changes the state of context `c`
--> example.veer:4:3
|
4 | for i in 0..3 { drop c }
| ^^^^^^^^^^^^^^^^^^^^^^^^
= note: to grow a context in a loop, consume and re-assign it: `c = c ++ "..."`
= help: run `veer explain V0104` for details