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.
Inference asks for help
An empty list has no element type to infer. Instead of inventing one, the compiler shows the annotation to write — with your variable name in it.
let xs = []The compiler answers
error: cannot infer the element type of an empty list — annotate the target, e.g. 'let xs: List[Int] = []' (line 1, column 10)let xs: List[Int] = []
print("{xs.len()}")Fixed — and it runs
0