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.

No null

null, nil and None-as-a-value let absence hide in any type. POLYTONE's absence is an Option, and the compiler checks every place it is opened.

broken.pt
let nickname = null
print("{nickname}")
The compiler answers
error: unknown name 'null' — there is no null: absence is an Option — 'None' / 'Some(x)', typed by its target ('let x: Option[Int] = None') (line 1, column 16)

ptc fix repairs this by itself: Change 'null' to 'None'