Errors
While compiling
The compiler shows where each mistake is and what it expected:
error: expected int, got string
--> main.cfl:2:6
|
2 | hp = "full"
| ^^^^^^ this is string
error: couldn't compile main (1 error)
When a name is almost right, it says so:
error: `scroe` doesn't exist
--> main.cfl:2:7
|
2 | print(scroe)
| ^^^^^
= did you mean `score`?
It keeps going after a mistake and reports as many as it can find at once. corfli check shows them without building.
While running
A few things stop a program with a message on stderr and exit code 1:
| message | when |
|---|---|
dividing by zero | / or % by 0, in every build |
this value doesn't fit in byte (0 to 255) | a conversion like byte(x) gets a value that's too big or too small |
this isn't a valid char | char arithmetic goes past the last Unicode letter |
the result doesn't fit in int (...) | a number overflows, in a debug build only |
out of memory | the system has no memory left |
Each message ends with the file, line and column:
error: dividing by zero
--> main.cfl:3:7
In a release build an overflowing number wraps around instead; see Operators.