POLYTONE — the AI-native programming language

Error Lab

Every diagnostic below is the real output of ptc, not a mock-up. Pick a mistake, read how the compiler teaches the canonical form, then flip to the fix.

Honest closures

Lambdas capture by value. Mutating a captured copy would silently do nothing to the original — so the compiler refuses and suggests the honest design.

broken.pt
mut seen = [1]
let track = fn(x: Int) -> Void = seen.push(x)
The compiler answers
error: 'seen' is captured by value in this lambda — mutating it would only change the lambda's copy; produce the result via the return value instead (line 2, column 34)