Errors
Compile errors
Each message below comes from the spec. The spec names the message, and the compiler must print it. Each row links to its section of the reference.
83 messages, listed by section.
| Message | Scenario | Section |
|---|---|---|
tabs are not allowed; indent with spaces | A tab in indentation is an error | 4. Lexical rules |
inconsistent indentation | Indentation must match an open block level | 4. Lexical rules |
unterminated string | A string must end on the same line | 4. Lexical rules |
unknown escape sequence | An unknown escape is an error | 4. Lexical rules |
x is an immutable binding and cannot be reassigned; declare it with mut x = ... to allow reassignment | A plain assignment makes an immutable binding | 7. Bindings |
x is already declared in this scope | A name cannot be declared mut twice in one scope | 7. Bindings |
x is an immutable binding and cannot be reassigned; declare it with mut x = ... to allow reassignment | An inner plain assignment cannot reassign a visible immutable name | 7. Bindings |
a declaration cannot have a trailing if; write it as an if: block | A declaration cannot end with if | 7. Bindings |
...rest must be the last name in a pattern | A rest name must be last | 8. Destructuring |
a pattern can only hold names, like {name, age: years} | A pattern holds only names | 8. Destructuring |
x is already declared in this scope | A pattern binds only new names | 8. Destructuring |
destructuring at the top level of a file with @wasm or @worker is not supported yet; move it into a function | A pattern at the top level of a file with @wasm or @worker is an error | 8. Destructuring |
destructuring is not supported in @wasm functions | A pattern in a @wasm function is an error | 8. Destructuring |
a mut parameter cannot have a default value yet | A mut parameter cannot have a default value | 9. Functions |
cannot pass immutable t to a mut parameter of f; declare it with mut | The argument must be a mutable binding | 10. Mutable parameters |
argument 1 of f is mut, so it must be the name of a mutable binding | The argument must be a plain name | 10. Mutable parameters |
mut parameters are not allowed on @worker functions | A mut parameter is not allowed on a @worker function | 10. Mutable parameters |
mut parameters are not allowed on class methods | A mut parameter is not allowed on a class method | 10. Mutable parameters |
h is exported, so it cannot take mut parameters; other modules cannot see them | An exported function cannot take a mut parameter | 10. Mutable parameters |
total is a top-level binding shared with the implementation module and cannot be changed from main-thread code; move the change into a function | Main-thread code cannot change a shared binding | 11. Shared bindings in worker files |
q is mutable top-level state, and each worker in a pool keeps its own copy; make it immutable, or remove pool | A file with a pool cannot declare a top-level mut binding | 11. Shared bindings in worker files |
requires and ensures must come at the top of a function body, before other statements | Contract lines come first in a body | 12. Contracts |
a parameter cannot be named result when the function has ensures; result is the return value there | A function with ensures cannot have a parameter named result | 12. Contracts |
requires and ensures are not supported on @memo, @worker, or streaming functions yet | Contracts are not allowed on @memo, @worker, or streaming functions | 12. Contracts |
requires and ensures are not supported in @wasm functions yet | Contracts are not allowed in a @wasm function | 12. Contracts |
a test block must be at the top level of the file | A test block is allowed only at the top level | 13. Tests and assertions |
typed hole: write the value here, _ is a placeholder | An underscore marks a value not yet written | 14. Typed holes, match, and comprehensions |
a binding cannot appear inside an | pattern | An alternative cannot bind a name | 14. Typed holes, match, and comprehensions |
this match may not handle every value; add a last arm _ => ... (or a name) to catch the rest | A match must handle every value | 14. Typed holes, match, and comprehensions |
else => must be the last arm | else must be the last arm | 14. Typed holes, match, and comprehensions |
this match: needs a last arm else => ..., so that every case is handled | A match without a subject needs an else arm | 14. Typed holes, match, and comprehensions |
a comprehension must start with a for clause | A comprehension must start with a for clause | 14. Typed holes, match, and comprehensions |
pin doesn't use == or ===. Write is to test equality | The symbol == is an error | 15. Ranges, values, and operators |
pin has no !=; write isnt to mean not equal | The symbol != is an error | 15. Ranges, values, and operators |
pin has no &&; write and to join two conditions | The symbol && is an error | 15. Ranges, values, and operators |
pin doesn't use ||. Write or to join two conditions | The symbol || is an error | 15. Ranges, values, and operators |
pin has no elif. Write else if for another condition | elif is an error | 16. Control flow |
break is only allowed inside a loop | break outside a loop is an error | 16. Control flow |
a try needs a catch or a finally block | try needs catch or finally | 17. Errors |
positional arguments must come before labelled ones | Positional arguments come before labelled ones | 19. Labelled arguments |
connect is given more than once | A label cannot name a parameter twice | 19. Labelled arguments |
connect has no parameter named timeout | A label must name a parameter | 19. Labelled arguments |
connect needs a value for host | A parameter without a default needs a value | 19. Labelled arguments |
labelled arguments only work when calling a function by its name | Labels work only when the callee is a name | 19. Labelled arguments |
a spread cannot be mixed with labelled arguments | A spread cannot be mixed with labels | 19. Labelled arguments |
type number is not allowed in @wasm functions; use int, float, or boolean | wasm parameters and results use only int, float, and boolean | 20. Types |
parameter n needs an int, float, or boolean annotation | Every wasm parameter needs an int, float, or boolean annotation | 20. Types |
@wasm f needs a return type annotation | A wasm function needs a return type | 20. Types |
unknown decorator @foo on function f | An unknown decorator is an error | 21. Decorators |
@wasm takes no options, but x was given | Only @worker takes options | 21. Decorators |
unknown option size on @worker; the only option is pool | pool is the only @worker option | 21. Decorators |
@memo cannot be combined with @wasm yet | @memo cannot be combined with @wasm | 21. Decorators |
@memo cannot be combined with @worker yet | @memo cannot be combined with @worker | 21. Decorators |
arithmetic needs int or float operands | Arithmetic needs int or float operands | 22. WebAssembly (@wasm) |
operands must have the same type, got int and float | Both operands must have the same type | 22. WebAssembly (@wasm) |
% needs int operands | % needs int operands | 22. WebAssembly (@wasm) |
ordering needs int or float operands | Ordering needs int or float operands | 22. WebAssembly (@wasm) |
and/or need boolean operands | and and or need boolean operands | 22. WebAssembly (@wasm) |
** is not supported in @wasm functions | ** is not supported in wasm | 22. WebAssembly (@wasm) |
g is not a @wasm function; @wasm code can only call other @wasm functions | Only calls by name to other @wasm functions are allowed | 22. WebAssembly (@wasm) |
unknown name n; @wasm functions can only use parameters, local bindings, and other @wasm functions | A name must be a parameter, a local binding, or a @wasm function | 22. WebAssembly (@wasm) |
strings is not supported in @wasm functions | Strings, arrays, and objects are not allowed in wasm | 22. WebAssembly (@wasm) |
loops over collections are not supported yet; use while | Loops over collections are not allowed in wasm | 22. WebAssembly (@wasm) |
nested function g is not allowed | A nested function is not allowed in wasm | 22. WebAssembly (@wasm) |
expected boolean but got int | A return value must match the return type | 22. WebAssembly (@wasm) |
worker arguments must be an array | Worker arguments must be an array | 24. Workers |
pool must be a whole number from 1 to 32, not 40 | A pool size outside 1 to 32 is an error | 24. Workers |
pool is given more than once | pool is given once | 24. Workers |
every @worker function in one file must use the same pool size | Every worker function in one file has the same pool size | 24. Workers |
mut parameters are not allowed on @worker functions | A @worker function cannot take a mut parameter | 24. Workers |
transfer needs an ArrayBuffer or a typed array | transfer needs a buffer | 25. Transfer |
transfer(...) must be a direct argument or result of a @worker call, not nested in another value | transfer must be a direct argument or a direct result | 25. Transfer |
yield is only allowed in a @worker function, directly in its body | yield is allowed only directly in a worker function body | 26. Streams |
a streaming @worker function cannot be async | A stream cannot be async | 26. Streams |
a streaming @worker function ends with a plain return; it cannot return a value | A stream cannot return a value | 26. Streams |
p needs at least one row that is matched, not only part rows | A regex block needs a row that is matched | 27. Regex blocks |
a regex row needs a pattern and then a name, like \d+ digits | A row needs a pattern and then a name | 27. Regex blocks |
<name> is not a part defined above it | An undefined part name is an error | 27. Regex blocks |
matches "x", but the pattern rejects it | matches and rejects examples are checked at build time | 27. Regex blocks |
unknown flag q; a regex block takes i, m, s, or u | An unknown flag is an error | 27. Regex blocks |
the flag i is given twice | A flag can appear only once | 27. Regex blocks |
uses lookaround, which the build check does not support yet | Lookaround is an error | 27. Regex blocks |
a block after name = is written regex: or find:, not pattern: | A block after a name must be regex or find | 27. Regex blocks |