Skip to content
Velt
Errors

Diagnostics#

The compiler reports errors as path:line:col: error: message, followed by notes (= note: …) and related locations (--> path:line:col). Compilation stops with exit code 1; nothing is run. An internal compiler error exits with code 101 and starts with internal compiler error; please report it.

The wording below is stable: tests, editors and tools rely on it.

SituationMessage
parseexpected expression, expected `;` , expected <token>, found <token>
unknown name or typecannot find `name` in this scope, cannot find type `T` in this scope
typesmismatched types + note expected i64, found string
conditionsan expression of type `void` cannot be tested for truthiness (also for a value of a generic type)
moves (promises, disposed values)use of moved value `name` (+ where it moved)
constcannot assign twice to const `name`
membersno field `x` on type `T` , `x` is private, property `#x` is not accessible outside class `A` because it has a private name, private names are only allowed in class bodies, the right operand of `in` must be an object, found `T` , cannot assign to `x`: it is a readonly field, cannot assign to `x`: it is a getter
unionsno field `r` on type `Shape` + "narrow it to one member first …"
switch`"square"` is not a possible value of `s.kind` + possible values: …, `continue` cannot target a `switch`
exclusive accesscannot use `xs` here: this call may modify it through another argument
threads"this async closure modifies captured n, so it must stay on the task that created it" (+ where it reaches spawn, a handler, shared or a channel, and the shared hint); "this code runs on another thread and calls i.onChange, which changes last" (+ where, and the declaration rewritten with shared(...)); "r is still used after spawn, so the task would get a copy, but T owns a resource ([Symbol.dispose]) and has no clone()" (or "… after send, so the receiving task would get a copy, …" for a channel, "this.conn stays where it is held, …", "Pair holds a Conn, which …"; + the fixes)
modules`x` is not exported, cannot assign to imported binding `x`, `export default` is not supported: Velt has named exports only, `T` is imported with `import type` and cannot be used as a value, namespace `ns` has no exported member `x`, a velt: specifier (an error; std modules are velt/<area>), `velt/encoding/json/scan` is internal to `velt/encoding/json`, cannot find module `velt/x` (+ the paths tried); the warning `main` is never called: in a file with top-level statements, the statements are the program and `main` is an ordinary function
overloadsno overload of `f` matches this call + a note per signature (TS2769), "this overload signature is not compatible with its implementation signature" (TS2394), function implementation is missing or not immediately following the declaration of `f` (TS2391), function implementation name must be `f` (TS2389), the TS2383, TS2387, TS2388 and TS2371 rules of signature declarations; at run time panic: overload `f` returned a `…` where its signature promises a `…`
interfacesthe type `C` does not implement `I` , `P` already implements `I`, conflicting implementations of `I`: neither block is more specific than the other (both fit `X`), `extend X` is missing method `m` required by `I`, `extend X` cannot implement `I`: … (fields, any, a union), an `extend` block that lists `implements` cannot bound `T` by `unknown`
async`await` is only allowed inside async functions, floating promise: this promise is neither awaited nor spawned (+ the await / spawn fixes)
errors`f` throws `E`, which its `throws` clause does not allow, `C.m` throws `E`, but `I.m` does not allow it, "this function throws E, but the function type it is used as does not allow throwing", "the error type of this function is not known yet"
syntax Velt doesn't have`mut` is not needed: mutation is inferred, `match` is not supported, "enum members cannot have payloads"; a postfix ? and a Result type are errors too (a call that throws propagates its error by itself; for errors as values, return a union such as User | NotFound)

At run time:

SituationOutputExit code
panicpanic: <message> at file:line:col101
uncaught errorUncaught <Type>: <message> at file:line:col (a thrown non-Error value: Uncaught <value>, as console.log prints it)1

The language server turns many of these diagnostics into quick fixes: removing mut, converting a + chain to a template literal, and adding await or spawn(...) to a floating promise (Editors).

Edit this page on GitHub