Reference
Errors
Errors
Every diagnostic code of narrac, with its message and, where there is one, its explanation. narrac explain CODE prints the same text. In a message, %s, %q, %d, %c and %v mark a name, text, number or character that the compiler fills in. A code with several messages is reported in several situations.
This page is generated by scripts/errors/generate.nra from narrac explain --list --json. Do not edit it.
E0000 to E0099: Lexer and parser
E0001
unterminated block comment
E0002
a character literal holds exactly one character; use double quotes for strings
E0003
semicolons are not used; end the statement with a line break
Narra has no semicolons. A line break ends a statement.
Fix: delete the ;.
Example: return 0; becomes return 0.
E0004
unexpected character %q
E0005
unterminated escape
E0006
expected { after \u
E0007
invalid \u escape
E0008
unknown escape \%c
E0009
unterminated literal
E0010
unterminated template string
E0011
expected %q, found %s
E0012
expected a name, found %s
E0013
expected the end of the statement, found %s
E0014
use `import * as Name from "path"` or `import { a, b } from "path"`; there are no default imports
Imports name the module as a namespace or list the names. There is no default import.
Fix: import X from "std/int" becomes import * as X from "std/int".
E0015
expected a module path string
E0016
implement blocks cannot be exported; export the trait and the type
E0017
tests cannot be exported
E0018
expected the test name as a string
E0019
expected a declaration, found %s
E0020
there is no `T[]` array type; write `Array<T>`
Arrays are written Array<T>, not T[].
Fix: xs: int[] becomes xs: Array<int>.
E0022
retired: generators are compiled now, so this error is no longer reported
E0023
a trait has no type parameters; use Self for the implementing type
E0024
a trait has functions only, found %s
E0025
trait functions have no default implementation; remove the body
E0026
functions in an implement block cannot be exported
E0027
an implement block has functions only, found %s
E0028
arrow function parameters cannot be mutable
E0029
unexpected end of file inside a block
E0030
write `for (const item of items)`
write `for await (const item of stream)`
E0031
use `of`; `for ... in` is not part of the language
E0032
a block must belong to a statement such as if or while
E0033
use `%s`; there is no strict equality operator
There is no strict equality. == already compares without conversions.
Fix: === becomes ==, and !== becomes !=.
E0035
a map key that is not a literal is written [key]: value
E0036
a struct literal has at most one spread, and it comes first
E0037
retired: a struct literal accepts field shorthand now, so this error is no longer reported
E0038
there is no %s; use `None` with an `Option` type
There is no null or undefined. A value that may be missing has type Option<T>.
Fix: null becomes None.
E0039
expected an expression, found %s
E0040
unterminated ${ in template string
E0041
in template string: %v
E0042
expected a number after - in a pattern, found %s
E0043
only an exported type can be opaque; write `export opaque`
E0044
expected `type` after `distinct`, found %s
E0045
expected `struct` or `distinct type` after `opaque`, found %s
E0046
a generator must be a top-level function; declare `function*` at module level
`yield` needs a value: write `yield value`, or `yield* generator`
`yield` is a statement, so it cannot be part of an expression
E0047
`from` needs the name of a parameter, found %s
E0100 to E0199: Declarations and types
E0100
unknown module %q (this compiler supports %s)
E0101
module %q has no export %q
E0102
function %q is declared twice
E0103
%q is already declared in this function; shadowing is not allowed
E0104
type %q is declared twice
E0105
field %q is declared twice
E0106
a field default must be a constant
E0108
generic type %s contains %s, so each instance needs a larger one without end; every instance needs its own C type, so polymorphic recursion is not supported (use the same type arguments, or an enum or Box)
E0109
type %s contains itself; put the recursive field in an enum, Box or array
E0110
Box takes one type argument
E0111
Map takes two type arguments
E0112
Array takes one type argument
E0113
there is no `number`; use `int` or `f64`
E0114
use `bool`
E0115
%s takes %d type arguments
E0116
there is no Tuple type; write a tuple type as #[A, B]
E0117
type %s is not generic
E0118
unknown type %q
E0119
expected %s, found %s
E0120
distinct type %s cannot be defined in terms of itself
E0190
constant %q is declared twice
E0191
constant %q is defined in terms of itself
E0192
constant %q cannot call function %q; a top-level constant holds literals, constructors, structs, arrays, function names and other constants
E0193
constant %q cannot use %s; a top-level constant holds literals, constructors, structs, arrays, function names and other constants
E0194
enum %s declares the constructor %q twice
E0195
generator %s must declare its return type as Generator<T> or Coroutine<In, Out>
the effects of generator %s are written on its return type, as in `Generator<T> uses io`
Generator takes one type argument
E0196
generator %s cannot take a mutable parameter %q; a generator is a value that is resumed later
E0197
Coroutine takes two type arguments
%s is not an export you can import by name; write `import * as Co from "std/coroutine"` and call Co.resume
E0200 to E0299: Expressions and statements
E0200
integer literal %s does not fit in int
E0201
a template string part must be a string, found %s; convert it, for example with Int.toString
E0202
a module is not a value
E0203
unknown name %q
E0204
struct %s has no field %q
E0205
this %s may hold any of its variants; check it with `is` or `match` before reading %q
E0206
%s has no field %q
E0207
%s has one field, value
E0208
there is no .length; use Array.length(x) or Str.length(x)
E0209
%s has no fields
E0210
only arrays can be indexed, found %s
E0211
- needs a number, found %s
E0212
the type of [] is unknown; add a type annotation
E0213
unsupported expression
E0214
cannot compare %s with %s
E0215
cannot order %s and %s
E0216
strings are joined with a template string, not +
Strings are joined with a template string.
Fix: a + "x" + b becomes `${a}x${b}`. The fix is offered when every operand is a string name or literal.
E0217
%s needs two numbers of the same type, found %s and %s
E0218
%s needs two integers, found %s and %s
E0219
unknown operator %s
E0220
cannot tell type parameter %s of %s here; add a type annotation
cannot tell constant parameter %s of %s here; write it, as in %s<3>(...)
cannot tell constant parameter %s of %s here; write it, as in %s<3> { ... }
cannot tell constant parameter %s of %s here; a function with a constant parameter cannot be a value
E0221
%q is not a struct
E0222
the struct type is unknown here; write `TypeName { ... }`
E0223
field %q is given twice
E0224
missing field %q of %s
E0225
this expression has no value
E0226
only variables, fields and array elements can be assigned
E0227
%q is constant; declare it with `let` to change it
parameter %q is read-only; declare it as `mutable %s` to change the caller's value, or copy it first with `copy(%s)`
E0228
this expression does nothing
E0229
this call returns a Result that is not checked; handle it, or discard it with `const _ = ...`
E0230
this function must return a %s
E0231
this function returns nothing
E0232
for ... of needs a Range, an Array, a Generator, Str.chars, Array.entries, Map.keys or Map.entries, found %s
E0233
break must be inside a loop
E0234
continue must be inside a loop
E0235
cannot read field %q of %s: it is an opaque struct of module %q
E0236
cannot spread %s: it is an opaque struct of module %q
E0237
the type arguments make %s, but the expected type is %s
E0290
constant %q cannot be changed; copy it into a local first with `copy(%s)`
constant %q cannot be changed; copy it into a local first, as in `let %s = %s`
E0291
%s cannot be used %s; it is valid only directly in a function* body
yield* needs a %s, found %s
E0292
return in a generator takes no value; yield the value, then return
E0293
the value of yield is available only in a coroutine; declare %s as Coroutine<In, Out>, or write `yield value` without a name
yield* is not valid in a coroutine; a delegated generator has no input to receive
Co.resume changes the generator; write Co.resume(mutable g) or Co.send(mutable g, input)
for ... of cannot iterate a coroutine, which needs an input on each resume; call Co.send(mutable g, input)
E0294
integer literal %s does not fit in %s
E0295
%s needs two integers of the same type, found %s and %s; convert one side with %s.from, %s.tryFrom or %s.wrap
%s needs two floats of the same type, found %s and %s; convert one side with F32.from or Float.from
E0296
- cannot negate %s, which is unsigned
E0297
float literal %s does not fit in f32
E0300 to E0399: Calls and constructors
E0300
constructor %s is ambiguous: %s all have it; write %s.%s
E0301
%s takes %d fields, found %d
E0302
cannot tell the type of %s here; add a type annotation
E0303
constructor fields are not mutable
E0304
enum %s has no constructor %q
E0305
unknown function %q
E0306
module %q has no function %q
E0307
unknown function %s
E0308
unknown module %q; import it first, for example `import * as %s from "std/..."`
E0309
there are no method calls; call a module function such as Module.%s(value, ...) (value has type %s)
Narra has no method calls. Functions belong to modules.
Fix: xs.push(v) becomes Arrays.push(mutable xs, v).
E0310
too many instances of generic functions; %s may recurse with ever larger types
E0311
%s takes %d arguments, found %d
E0312
%s changes its argument; write `mutable` before it
E0313
%s does not change its arguments; remove `mutable`
E0314
a mutable argument must be a variable, a field or an element
E0315
parameter %q is read-only; declare it as `mutable %s` to pass it on as mutable
E0316
this call passes %d arguments, the function takes %d
this call passes %d arguments, the function takes %d to %d
E0317
parameter %q is mutable; write `mutable` before the argument
E0318
parameter %q is not mutable; remove `mutable`
E0319
%q is passed as mutable in this call, so no other argument can use it
E0320
cannot build %s with a literal: it is an opaque struct of module %q; use that module's functions
E0321
%s.%s is not available outside module %q: %s is an opaque distinct type
E0322
%s has no function %q; a distinct type has %s
E0323
constructor %s needs its enum; write %s.%s
A constructor of a user enum is always written with its enum, in expressions and in patterns. Some, None, Ok and Err stay bare.
Fix: Circle(1.0) becomes Shape.Circle(1.0).
E0324
constructor %s needs its enum; %s all have it, for example %s.%s
Two enums visible here have this constructor, so the compiler cannot pick one.
Fix: write Enum.Name for the one you mean, for example Level.Low.
E0325
expected %s, found %s; the argument does not fit the generic parameter
A generic function was called with an argument that cannot match its parameter, for example an int where Option<T> is expected.
Fix: pass a value of the shape the parameter asks for.
E0326
%s is not a generic function, so it takes no type arguments%s
Explicit type arguments, as in f<int>(x), only go with a generic function or a trait function.
Fix: delete the type arguments, or call a generic function.
E0327
%s takes %d type arguments, found %d
A generic function takes one type argument per type parameter, all or none. A trait call takes one, the type that Self stands for.
Fix: write every type argument, or none and let the arguments decide.
E0328
%s has no parameter %q
%s has no parameter %q; did you mean %q?
E0329
parameter %q is passed twice
E0330
a positional argument cannot follow a named one; name it, or move it before the named arguments
E0331
this call passes no argument for parameter %q
E0332
%s has no parameter names; pass its arguments by position
E0400 to E0499: Modules, packages and narra.toml
E0400
the entry function must be `export function %s(args: Array<string>): int`
E0401
unknown module %q; package %s has no file src/%s.nra
E0402
%q is not exported by module %q; add `export` to its declaration
E0403
unknown module %q in type %s; import it with `import * as %s from "..."`
E0404
%s is not a type
E0405
expected `]]`
E0406
expected `]`
E0408
expected `key = value`
E0409
%s: %v
E0410
package name must be a string of letters, digits and `_`, starting with a letter
E0411
package name "std" is reserved for the standard library
E0412
%s must be a string
E0413
%s must be an array of strings
E0414
[package] needs a name
E0415
each [[binary]] needs a name and an entry such as "cli.run"
E0416
two [[binary]] entries are named %q
E0417
modules %q and %q have the same C name hash; rename one file
E0418
import cycle: %s
E0419
no entry function; declare `export function run(args: Array<string>): int`
E0420
binary %q: no entry function %q; declare `export function %s(args: Array<string>): int` in module %q
E0421
the import alias %s is also a type name; rename it, for example `import * as %s from %q`
E0422
two imports use the alias %s; give one of them another alias
E0423
imported name %q is already declared in this module; rename the import with `as`
E0424
imported name %q is already imported from another module; rename one with `as`
E0425
%q is a constructor of %s; import the enum and write %s.%s
Importing a constructor by name is not allowed. Import the enum; its constructors come with it.
Fix: import { Teacher } becomes import { SchoolPerson }, and uses become SchoolPerson.Teacher.
E0430
dependency %s needs a git and a version
E0431
version %q is not MAJOR.MINOR.PATCH
E0432
dependency %s has an unknown or repeated key %q; it takes git and version
E0433
a dependency cannot be named %s: it is the standard library or this package
E0434
two dependencies are named %q
E0435
dependency %s is not a valid inline table: %s
E0436
dependency name %q must be letters, digits and `_`, starting with a letter
E0437
bad line: %s
E0438
entry %s has the unknown key %s
entry %s is missing the key %s
entry %s repeats the key %s
entry %s has the tag %s, which is not the tag of version %s
E0439
two entries are named %q
E0440
git was not found on PATH
E0441
cannot read the repository %s: %s
E0442
the repository %s has no tag %s
E0443
the cached version %s has tree %s, but %s was expected
E0444
no cache folder: set NARRA_CACHE or HOME
E0445
cannot check out %s of %s: %s
E0450
package %s is required from two repositories, %s and %s, and [overrides] has no entry for it
package %s is a member of the workspace and is also required from %s
E0451
the repository %s has no tag for version %s of %s
E0452
narra.lock records commit %s and tree %s for %s %s, but the repository has commit %s and tree %s
E0453
the manifest of %s %s names the package %q
E0454
[overrides] is allowed in the root manifest of a build only, not in %s
E0455
[overrides] has an entry for %s, but no package requires it
E0456
the override for %s names version %s, which has no tag in %s
E0457
%s has no narra.toml
E0458
cannot read or write %s: %s
E0460
%s %s is not in the cache; run narrac build to fetch it
E0461
narra.lock has no entry for %s %s from %s; run narrac build to update it
E0462
the dependency %s has no .nra files in src/
E0463
package %s imports %s, but its narra.toml has no [dependencies] entry for it
E0470
export key %s must be the package name %s or start with %s
E0471
export %s names %s, which is not a module file; write a path such as "src/index.nra"
export %s must be a string, the module file such as "src/index.nra"
export %s names %s, but the package has no such file
E0472
two exports are named %q
E0473
%s does not expose %s; it exposes %s
E0474
%s is internal to the standard library
E0480
[workspace] members must be an array of strings
[workspace] has the unknown key %s; it takes members
[workspace] needs members
the member entry %q must be a relative path, with `*` only as a whole segment and no `..`
E0481
the member %s has no narra.toml
the member %s has its own [workspace]
E0482
two members are named %q: %s and %s
E0483
dependency %s takes no other key beside workspace
dependency %s: workspace must be true
override %s takes git and version, not workspace
E0484
%s depends on %s with workspace = true, but the workspace has no member named %s
%s depends on %s with workspace = true, but it is not a member of a workspace
E0485
%s is inside the member %s; the workspace keeps one lock at %s
E0486
the checkout of %s %s has no package named %s
E0487
%s needs its sibling %s, which has no version
%s needs %s %s, but the repository %s has no tag for it
E0488
the members %s and %s both have a binary named %s; binary names must be unique in a workspace
E0489
%s needs the directory of a workspace member; %s is not one
%s needs the directory of a workspace member; %s is the workspace root, which covers every member
E0490
the member %s depends on itself through workspace = true dependencies
E0500 to E0599: Traits
E0500
%q is declared twice
E0501
%s is listed twice in `implements`
E0502
derives Shape is not supported by this compiler yet
E0503
%s cannot be derived; only Equatable, Hashable, Ordered, Show and Shape can. List it in `implements` and write `implement %s for %s`
E0504
%s is listed twice in `derives`
E0505
unknown trait %q
E0506
%s is listed twice in the constraint of %s
E0507
%s implements %s but has no `implement %s for %s` block
%s implements %s but has no `implement %s for %s` block or `derives %s`
E0508
%s both derives and implements %s; keep one
E0509
cannot derive %s for %s: field %q has type %s, which does not implement %s
E0510
trait functions cannot have type parameters in this compiler yet
E0511
%s declares function %q twice
E0512
%s.%s must use Self in a parameter or its result, so a call can tell which implementation to run
E0513
cannot implement %s for %s: the type is declared in another module; wrap it in a struct
E0515
%s does not list %s in `implements`; add `implements %s` to its declaration
E0516
%s is implemented twice for %s
E0517
functions in an implement block cannot have type parameters in this compiler yet
E0518
trait %s has no function %q
E0519
function %q is implemented twice
E0520
%s.%s for %s must be `%s`
E0521
implement %s for %s is missing function %s
E0522
cannot tell which type's %s.%s to call here; add a type annotation
E0523
%s.%s needs %s to implement %s; declare it as <%s: %s>
E0524
%s does not implement %s
E0525
%s does not implement %s, which %s needs for type parameter %s
E0526
cannot use == on %s: it contains a function
E0527
== on %s needs Equatable; declare the type parameter as <T: Equatable>
E0528
%s does not implement Equatable
E0529
%s.%s has Self only in its result; name the type, as in %s.%s<Type>(...)
No parameter of this trait function mentions Self, so the call alone cannot tell which implementation to use.
Fix: name the type: Shape.fromValue<User>(value).
E0530
%s does not implement Shape: %s
Shape converts a type to and from a Value tree. The compiler provides it for bool, int, f64, char, string, Array<T>, Map<string, V>, Option<T> and tuples of two to four items whose contents implement it. A struct or enum needs an implement Shape block. A Map with keys other than string, a function and a sized integer have no Value form.
Fix: use a Map<string, V>, or wrap the type in a struct that implements Shape.
E0531
cannot derive Shape for %s: field %q has type %s, which does not implement Shape: %s
derives Shape writes toValue and fromValue from the fields, so every field type must implement Shape itself.
Fix: give the field a type that implements Shape, or write an implement Shape block for the type instead of deriving it.
E0532
%s derives Shape, so %s.%s cannot have a field named "type": the encoding writes the constructor name there
A derived Shape writes an enum value as a Record whose "type" entry names the constructor, as a TypeScript discriminated union does. A constructor field named type would take the same key.
Fix: rename the field, or write an implement Shape block for the enum.
E0533
%s is an opaque struct that derives Shape; its Shape is usable only in its own module
Other modules cannot build an opaque struct or read its fields, and a derived Shape does both, so only the struct's own module may use it.
Fix: convert the value in the declaring module, or write an implement Shape block that keeps the struct's rules.
E0600 to E0699: Closures and function values
E0600
only a parameter with a function type can be escaping
E0601
parameter %q cannot escape: it can only be called or passed to a function parameter that is not escaping; declare it as `escaping %s` to store, return or capture it
E0602
a closure cannot capture parameter %q because it is not escaping; declare it as `escaping %s`
E0603
a closure cannot capture mutable parameter %q; copy it first with `copy(%s)`
E0604
a closure cannot capture %q because it is declared with let; closures capture only constants
E0605
function %s has a mutable parameter, so it cannot be used as a value
E0606
%q is a %s, not a function
%q is a %s, not a function; if `<` is a comparison, wrap it in parentheses, as in `(%s < %s)`
E0607
this expression cannot be called
E0608
a function value takes no mutable arguments; remove `mutable`
E0609
%q is passed as mutable inside this call, so it cannot also hold the function being called
E0610
this arrow function takes %d parameters, but the expected function takes %d
E0611
cannot tell the type of parameter %q; write it as `%s: Type`
E0612
a closure cannot capture %q because it is declared with let, unless it is passed straight to a function parameter that is not escaping; to share state that changes with an escaping closure, keep it in a Cell from std/cell
E0613
a closure cannot capture mutable parameter %q unless it is passed straight to a function parameter that is not escaping; copy it first with `copy(%s)`
a closure cannot capture loop element %q, which is changed in place, unless it is passed straight to a function parameter that is not escaping; copy it first with `copy(%s)`
E0614
%q is assigned by a closure passed to this call, so no other argument can use it
E0615
parameter %q of generator %s has a function type, so it must be `escaping`: the generator outlives the call
E0700 to E0799: Patterns and match
E0700
%s is not a constructor of %s; a name that binds starts with a lowercase letter
E0701
%q is bound twice in this pattern
E0702
constructor pattern %s needs an enum value, found %s
E0703
%s.%s does not match a value of type %s
E0704
%s has %d fields, the pattern lists %d
E0705
a struct pattern needs a struct value, found %s
E0706
field %q is listed twice
E0707
a tuple pattern needs a tuple value, found %s
E0708
%s has %d elements, the pattern lists %d
E0709
a literal pattern needs an int, f64, bool, char or string value, found %s
E0710
an `is` pattern can only bind names when it is the whole condition of an if or a conditional expression
E0711
match needs a value, found void
E0712
a match used as a value needs a single expression in each arm
E0713
match does not cover every %s value; add a `_` arm
E0714
match does not cover %s; add the cases or a `_` arm
E0715
this pattern does not match every %s; use match or `is` to test a value
E0716
a spread needs a struct value, found %s
E0717
cannot spread %s into a %s literal; the spread must have the literal's type
E0718
a tuple type needs at least two element types, found %d
E0719
a tuple needs at least two elements, found %d
E0720
cannot match the fields of %s: it is an opaque struct of module %q
E0722
`...` must be the last element of an array pattern, and appear once
E0723
%s holds %s elements, but this pattern matches %s
the length of %s is a constant parameter, so only `[..._]` matches every value; use match or `is` to test the length
E0724
the rest of a %s pattern cannot have a name, since its length would be N minus the elements before it; write `..._` and index the array
E0726
an array pattern needs an Array or FixedArray value, found %s
E0800 to E0899: Effects
E0800
Function `%s` uses `%s`%s but its signature does not declare it; write `uses %s`
the implementation of `%s` declares `uses %s`, but the trait function does not; an implementation may use only the effects its trait function declares
the implementation of `%s` uses `%s`%s, but the trait function does not declare it; an implementation may use only the effects its trait function declares
E0801
unknown effect `%s`; the effects are alloc, io and unsafe, or an effect variable declared as `<effect %s>`
E0802
effect variable `%s` in the `uses` list of `%s` must appear in the function or generator type of a parameter
E0803
the argument for `%s` of `%s` uses `%s`, but its function type does not declare it; write `uses %s` in the type, or `uses E` with `<effect E>` on `%s`
E0900 to E0999: Standard library
E0900
%s cannot be a map key: %s
E0901
the type of Map {} is unknown; add a type annotation
E0902
%s needs a map, found %s
E0903
Map.remove changes the map; write Map.remove(mutable m, key)
E0904
%s needs an array, found %s
E0905
Array.push changes the array; write Array.push(mutable items, value)
E0906
%s needs an array, found %s
E0907
%s can only be called inside a `test` block
E0908
%s.%s needs an import; add `import * as %s from %q`
E0909
%s needs an Option<T>, found %s
E0910
%s needs a Result<T, E>, found %s
E0911
%s needs a function as argument %d, found %s
E0912
%s needs a function that returns %s, found one that returns %s
E0913
%s needs a function that returns a value
E0914
%s.%s names a type; this module imports %q as %s
E0915
mutable parameter %q cannot be returned or stored; copy it first with `copy(%s)`
loop element %q is changed in place, so it cannot be returned or stored; copy it first with `copy(%s)`
E0916
no enclosing loop is labeled %q
E0917
label %q is already used by an enclosing loop
E0918
label %q must be on a for or while loop
E0920
%s can only be the source of a for ... of loop; use the array itself
E0921
%q is never read; remove it, or name it %q to mark it as unused on purpose
E0922
parameter %q is never read; remove it, or name it %q to mark it as unused on purpose
E0923
there is no `class`; use a `struct` and functions in a module
Narra has no classes. Data goes in a struct and behavior in functions of the module.
Fix: class A {} becomes struct A {}.
E0924
there is no `interface`; use a `struct` for data or a `trait` for behavior
Narra has no interfaces. Use a struct for a data shape and a trait for behavior.
Fix: interface A {} becomes struct A {}.
E0925
there is no `new`; write a struct literal such as `Name { field: value }`, or call a function
Narra has no new. A struct is built with a literal, other values with a function call.
Fix: new A() becomes A {} when A is a struct without fields.
E0926
there is no `try` or `catch`; return a `Result` and check it with `is Err` or `match`
Narra has no exceptions. A function that can fail returns Result<T, E>; the caller checks it with is Err or match.
E0927
there is no `throw`; return `Err(value)`, or call `panic` for a bug
Narra has no throw. Return Err(value) from a function that returns a Result.
Fix: throw "x" becomes return Err("x").
E0928
there is no `this`; pass the value as a parameter
Narra has no this. A function gets the value as a parameter.
E0929
%q is passed as mutable in one call, so the rest of the expression cannot use it
E0930
a function inside a function is not supported; declare it at module level as a private function and pass the enclosing values as arguments
Narra has no function declarations inside a function. Declare the function at module level as a private function and pass the enclosing values as arguments.
There is no automatic fix: moving it changes the meaning when its body reads a name that a local shadows, and breaks helpers that use the enclosing type parameters.
For a helper that captures, bind an arrow function: const helper = (x: int): int => x + offset.
Example: function run() { function add(a: int): int { return a + 1 } } becomes function add(a: int): int { return a + 1 } followed by function run() { ... }.
E0931
a block expression must end every path with `return value`
E0932
%s cannot leave a block expression; it can only leave a loop inside the block
E0933
a block expression needs `return value`; Narra has no object literals, so write a struct literal such as `Point { x: 1 }`
E0934
a conditional expression needs `:` and a second value, as in `cond ? a : b`
a conditional expression that spans lines must be wrapped in parentheses, as in `(cond ? a : b)`
both branches of a conditional expression must have a value
the value of a conditional expression must be used; write an `if` statement instead
E0940
%s cannot take %s without loss; use %s.tryFrom or %s.wrap
E0941
%s takes an integer, found %s
%s takes %s or an integer, found %s
E0946
%q is imported but never used; remove it, or import it as %q to mark it as unused on purpose
E0947
private function %q is never used; remove it, or name it %q to mark it as unused on purpose
E0948
a mutable parameter needs a type whose contents change in place (a struct, Array, Map, Box, StringBuilder or Generator), found %s; return the new value instead
E0949
mutable parameter %q cannot be assigned whole; `mutable` reaches its fields and elements, so return the new value instead
E0950
%q is a copy of an element of %s, so changing it would not change %s; write `for (mutable %s of %s)`, or copy it first with `copy(%s)`
%q is a copy of an element of %s, so changing it would not change %s; write through the source, `%s[index]%s`, or copy it first with `copy(%s)`
%q is a copy of an element, so it cannot be changed; copy it first with `copy(%s)`
%q is bound by a pattern to a copy of part of the value, so it cannot be changed; copy it first with `copy(%s)`
%q is destructured from a copy of the value, so it cannot be changed; copy it first with `copy(%s)`
E0951
a closure cannot change captured %q unless it is passed straight to a function parameter that is not escaping; copy it first with `copy(%s)`
E0952
%s.%s takes `mutable Self`, so %s can only be implemented for a type whose contents change in place (a struct, Array, Map, Box, StringBuilder or Generator), not %s
E0954
`#[%s, mutable %s]` needs `Arrays.entries(items)` as the source; without the index, write `for (mutable %s of items)`
Arrays.entries gives #[index, item] tuples; write `for (const #[index, mutable %s] of Arrays.entries(items))`
`for (mutable ...)` changes the elements of an Array in place, found %s
the source of `for (mutable ...)` must be a variable, a field or an element, so the loop can change it in place; store the array in a local first
E0955
the elements of %s are %s, which have no contents to change in place; write `%s[%s] = ...` in a `for (const #[%s, %s] of Arrays.entries(%s))` loop
E0956
%q cannot be used inside the loop that changes %s in place; reach its elements through %s, or write an index loop
E0957
`for (mutable ...)` is not supported in a function* body yet; change the elements through an index, as in `items[index].field = value`
E0958
loop element %q cannot be assigned whole; `mutable` reaches its fields and elements, so assign those, or write an index loop to replace the element
E0959
the condition of a for loop must be a bool, found %s
E0960
the first part of a for loop must be `let`, because the step changes it
E0961
the last part of a for loop must be an assignment or a call
E0962
%s needs a value of the same type as its target, found %s and %s
%s cannot be applied to %s
E0963
%s needs an integer variable, found %s; write `x += 1` for a float
E0964
compound assignments and `++` are statements; they have no value, and `++x` is written `x++`
there is no prefix `%s`; write `x%s` as a statement
E0965
cannot use == on %s: a Cell is shared by identity; compare the values with Cells.get
E0967
%q is bound in one alternative but not in the other; every alternative binds the same names
E0968
%q has type %s here and %s in the first alternative; every alternative binds the same types
E0969
this function must return %s on every path, but %s
E0970
this arrow function must return %s on every path, but %s
E0971
%s would be a second name for the %s in %s; use %s, or copy(%s) for %s of its own
E0972
type alias %s refers to itself; a recursive type needs an enum
E0973
type alias %s takes %s type arguments, found %s
E0974
this alternative is unreachable: the arms and alternatives before it already match every value it matches
an `is` test takes one pattern, not alternatives; use `match` to list alternatives
a destructuring takes one pattern, not alternatives; use `match` to list alternatives
E0975
copy takes one argument, found %s
copy does not change its argument; remove `mutable`
copy of %s copies nothing: a value of this type is never changed in place; remove the call
E0976
the result shares parameter %q; write `from %s` after the result type
the result shares parameter %q, but the from marker names %q; return a copy with copy(...)
the arrow function returns a value that shares captured %q; a from marker can name only a parameter, so return a copy with copy(...)
the async block returns a value that shares captured %q; return a copy with copy(...)
the arrow function returns a value that shares its parameter %q, which its function type does not allow; return a copy with copy(...)
the arrow function returns a value that shares its parameter %q; write the result type with `from %s`, or return a copy with copy(...)
from names %s, which is not a parameter of %s
from names %s, which is not a parameter of this function type; name the parameter, as in `(%s: T) => R from %s`
from names %s, which is not a parameter of this arrow function; a from marker can name only a parameter
E0977
this function's result shares its parameter %s, but the expected type %s has no matching from; add `from` naming that parameter to the expected type
E0978
%s may change %s, which %s still uses at line %s%s
%s may change %s, which %s still holds for the caller%s
%s may change %s, which captured %s still holds%s
%s may change %s, which the cell %s still holds%s
%s may change %s, which constant %s still holds%s
%s may change %s, which the loop over %s still holds; change it after the loop, or loop over a copy(...)
E0979
the divisor must be a non-zero constant or a name checked against zero first; %s
E0980
the shift count must be a constant from 0 to %s or a name checked against both ends first; %s
E0981
typeof %s refers to its own declaration; write the type out
typeof %s is part of the cycle %s; write one of the types out
E0982
typeof needs a value, but %q is a type; write the type itself, or the name of a const, let, parameter or function
typeof needs a value, but %q is a module; name a const, let, parameter or function
typeof %s has no function type to write: a generic function, one with effect variables and one with a mutable parameter cannot be used as a value
typeof %s has no function type to write: a function with requires cannot be used as a value
E0983
this arm is unreachable: the arms before it already match every value it matches
E0984
requires is not allowed on a function of an implement block; a call through the trait cannot prove it
requires compares integer parameters with integer constants or with each other, joined by && and ||; %s
requires needs a function body; a trait function has none, so state it on the implementations
E0985
this argument is not proven to meet `requires %s` of %s; pass a constant, or a name checked first with an `if`
%s does not satisfy `requires %s` of %s
%s do not satisfy `requires %s` of %s
E0986
function %s has a requires condition, so it cannot be used as a value; call it directly
E0987
the comparison pattern `%s` needs an integer value, found %s
ensures describes the result, and this function returns nothing
an ensures pattern binds no names, found %s; write `_` for any value
the bound of `%s` does not fit the type %s
the literal %s cannot be proven for type %s; the prover keeps integers as int and cannot prove 2^63 - 1, -(2^63 - 1) or a u64 from 2^63 up
ensures needs a function body; a trait function has none, so state it on the implementations
the bound of `%s` must be an integer constant: a literal or a top-level const
an ensures pattern cannot be an array pattern; the prover keeps no facts about array lengths
E0988
this value is not proven to match `ensures %s`; write a constant, a constructor, or a name checked first with an `if`
the values of yield* are not proven to match `ensures %s`; yield each value after a check
E0989
std/build has no target for this host (%s); the supported targets are %s
could not determine the host: %s
E0990
`@%s` is written once, before a function declaration
unknown attribute @%s; the known attributes are %s
`@%s` is not allowed in an implement block; only @trusted is
@%s %s takes a variant such as Os.Windows
@target needs os, arch or both, such as @target(os = Os.Windows)
@target takes os and arch, not %s
@target names %s twice
@%s takes one string, as in @%s("name"), found %s
%s of std/build has no variant %s
@target takes %s from std/build here, not %s
E0991
%s exists only on @target(%s), but this use is compiled for %s; use it inside an if on Build.os or Build.arch that keeps it only on that target
%s is not available on Wasi, but this use is compiled for %s; use it inside an if on Build.os that drops Os.Wasi
A @target function exists only on its target, so a use must sit where only that target compiles it: inside an if on Build.os or Build.arch that the other targets drop, or inside a @target function with the same or a narrower target. An ordinary if, a match and an early return do not count.
narrac check checks the host only; narrac check --all-targets checks every supported target.
Example: print(linuxName()) becomes if (Build.os == Os.Linux) { print(linuxName()) }.
E0992
a constant type parameter must have type int, found %s
constant type parameters are allowed only on functions and structs
a type argument cannot compute with `%s`; write an integer literal or a constant parameter
A constant type parameter is written const N: int in the type parameters of a function or a struct. Its kind is int; enums, type aliases and other integer kinds do not take one. A type argument is a type, an integer literal or a constant parameter in scope; it never computes.
Example: Vector<N + 1> is rejected; pass the length as its own constant parameter, function grow<const N: int, const M: int>(vector: Vector<N>): Vector<M>.
E0993
%s is a constant, not a type; only a constant type parameter takes it
%s is a constant type parameter, not a type
the constant %s for %s does not fit an int
constant parameter %s takes an integer literal or a constant parameter, found %s
A constant parameter takes an integer literal or a constant parameter in scope, and a type parameter takes a type; the two do not mix. A local, a type or a top-level constant cannot stand for a constant parameter, and a constant cannot stand for a type.
Example: Vector<count> becomes Vector<3>, and value: N becomes value: int with N read in the body.
E0994
index %s is out of range for %s, whose indexes are %s%s
the index of %s must be proven to be %s; %s%s
Indexing a FixedArray has no runtime check, so every index is proven at compile time. A constant index must be from 0 to N - 1. Any other index must be a plain name that a check puts in that range: an if or while condition such as i >= 0 && i < 4, the condition of for (let i = 0; i < N; i++), or for (const i of Ranges.upTo(N)). An assignment to the name ends what the check proved. FixedArrays.get(values, i) returns an Option for any index.
Example: values[i] becomes if (i >= 0 && i < 4) { use(values[i]) }.
E0995
the length of a FixedArray cannot be negative, found %s
the length %s of a FixedArray does not fit an int
the length of a FixedArray is an integer literal or a constant parameter, found %s
FixedArray takes an element type and a length, as in FixedArray<int, 4>
a literal cannot build %s: its length is a constant parameter, which the generic declaration does not know
%s needs %s elements, found %s
%s takes more than %s bytes, the limit for a FixedArray; use an Array
FixedArray<T, N> takes an element type and a length. The length is an integer literal or a constant type parameter, and never negative. One FixedArray value takes at most 1048576 bytes (1 MiB); use an Array for more. A literal builds a FixedArray when the expected type is one, and gives every element.
Example: const point: FixedArray<f64, 3> = [1.0, 2.0, 3.0].
E0996
%s is unsafe; call it inside an `unsafe { }` block
%s runs unsafe code; iterate it inside an `unsafe { }` block
A call of a std/ptr function or of a function with the unsafe effect may break memory safety, so it is allowed only inside an unsafe { ... } block. The function that holds the block gets the unsafe effect, unless it is marked @trusted.
Example: const value = Ptr.read(items) becomes let value = 0 followed by unsafe { value = Ptr.read(items) }.
E0997
@trusted on %s, which has no `unsafe` block; remove @trusted
%s is @trusted, so it does not have the unsafe effect; remove `uses unsafe`
@trusted states that a function's unsafe blocks were checked by hand, and stops the unsafe effect there: callers need no unsafe block. A function without an unsafe block has nothing to trust, and a @trusted function does not declare uses unsafe.
Example: remove @trusted from a function that has no unsafe block.
E0998
Ptr takes one type argument
Ptr<%s> is not allowed: %s; a pointer may point at numbers, bool, char, Ptr and structs of those
%s takes a Ptr, found %s
%s takes its element type from where the result goes, as in `%s`
A Ptr<T> is a raw pointer with no reference count. It may point at numbers, bool, char, another Ptr and structs whose fields are all such values, because a pointer to a string, array, map, box, enum or closure would bypass reference counting. The std/ptr functions take a Ptr; Ptr.alloc, Ptr.null and Ptr.cast take the element type from where the result goes.
Example: Ptr<string> is rejected; const items: Ptr<int> = Ptr.alloc(4) works.
E1000 to E1099: C interop and unsafe code
E1000
@extern is written on a function inside an `extern { } from` block
an extern block ends with `from "library"`, found %s
%q is not a library name; write the name cc takes after -l, such as "m"
an extern block declares at least one C function
@%s is not written on a function of an extern block; only @extern is
an extern block holds only function signatures, found %s
%s in an extern block cannot be generic or a generator
%s in an extern block has the unsafe effect already; remove `uses`
%s in an extern block has no body; the C library provides it
unknown key %s in [link]; [link] takes search
C functions are declared in a block that names their library: extern { function sqrt(value: f64): f64 } from "m". A member is a signature with no type parameters, no uses and no body; it has the unsafe effect. Only @extern("name") may stand before a member. The libraries come from from, so [link] in narra.toml takes only search.
Example: [link] libraries = ["m"] is removed; write from "m" after the extern block.
E1001
"%s" is not a C name; a C name is letters, digits and _, not starting with a digit
the C name %s clashes with %s that the compiler writes; give the function another name with @extern
A C function is linked by its C name, the member's name or the one @extern gives. That name must be a C identifier and must not be one the compiler writes itself: main, names starting with narra_ or lstr_, string literal names such as L1, and the generated names of the program's functions and types, alone or with a helper's operation before or a suffix after (release_E_Option_e088c655).
Example: @extern("narra_alloc") is rejected; call the C function by its own name.
E1002
%s of C function %s has type %s; a C function takes numbers, bool and Ptr<T>
C function %s returns %s; a C function returns numbers, bool, Ptr<T> or nothing
A C function takes and returns values C can pass: the number types, bool and Ptr<T>, and may return nothing. Strings, arrays and other counted values have no C form; pass a Ptr<u8>, for a string CStrings.pointer of a CString.
Example: function strlen(text: string): u64 becomes function strlen(text: Ptr<u8>): u64.
E1003
the type of constant %q is not known here; write it as `const %s: Type = ...`
typeof of a constant needs the constant's type, and a constant without a written type has its type only after its value is checked. In a declaration of the same module (a signature, a field, an alias) that type is not known yet, so write it.
Example: const limit = 3 becomes const limit: int = 3.
E1004
a source line or column must be below %s; split the file or the line
The compiler tracks a position as a line and a column below 1048576 each. A token past either limit is rejected, since it would share a record with another position. Split the file, or break the long line.
E1010
a tuple index must be a constant integer; use a pattern such as `const #[first, second] = pair` to read the elements
A tuple element is read with a constant index, pair[0], so the read is a field read and cannot fail. An index that is a let, a parameter or any other computed value is rejected, because the element type would depend on it. A top-level const works. To read every element, destructure the tuple.
Example: pair[count] becomes const #[first, second] = pair.
E1011
index %d is out of range for %s, whose indexes are 0 to %d
A tuple has a fixed number of elements, and a constant index must name one of them, counting from 0. Tuple elements are read-only, so pair[0] = 2 is E0226.
Example: for #[int, string], the indexes are 0 and 1; pair[2] and pair[-1] are rejected.
E1012
cannot derive %s for %s: its base type %s does not implement %s
A distinct type has the representation of its base type, so a derived trait is the base type's: distinct type UserId = int derives Show prints as an int. The derive needs the base type to implement the trait.
Example: distinct type Handle = Ptr<int> derives Show is rejected, since a pointer has no Show; write an implement Show for Handle block and list implements Show.
E1013
%s cannot be used as a value: %s; wrap it in an arrow function, such as `%s`
A standard function is a value when its signature is fixed: Int.toString, Str.length, Fs.readText. A function whose types depend on the call (Arrays.length, Maps.size), one with a mutable parameter and one that takes a function argument have no single signature, so they are not values.
Example: write the arrow function (items) => Arrays.length(items) instead of Arrays.length.
E1014
cannot implement %s for %s: %s on a distinct type compares the base value (D62)
==, != and map keys on a distinct type compare and hash the base value, so an implement Equatable or implement Hashable block for it would never run and is rejected. Write the comparison as a function of the declaring module, or wrap the value in a struct.
Example: implement Equatable for UserId is rejected for distinct type UserId = int.
E1020
%s does not implement %s, which %s needs for type parameter %s
%s does not implement %s, which %s needs for type parameter %s; declare it as <%s: %s>
A struct or enum can require traits of its type parameters, as in struct Labeled<T: Show>. Every use of the type with arguments must meet them: a written type, a struct literal and an enum constructor. A type parameter of the enclosing function or type meets a constraint only when it declares the same trait; constraints are not implied.
Example: function first<T>(pair: Labeled<T>) is rejected; write function first<T: Show>(pair: Labeled<T>).
E1021
`implement %s for %s` must name the type as %s, with the type parameters of its declaration in order
An implement block for a generic struct or enum names the type with the type parameters of its declaration, by the same names and in the same order. The block adds no constraints of its own: the members see the constraints the declaration gives, and the block holds for every instance.
Example: for struct Pair<T>, implement Show for Pair<int> and implement Show for Pair are rejected; write implement Show for Pair<T>.
E1022
Dynamic takes one trait argument
Dynamic takes a trait, and %s is not a trait
Dynamic<Trait> holds a value of any type that implements one trait, so its one type argument is a trait name. Dynamic<int>, Dynamic alone and Dynamic<Show, Ordered> are rejected.
Example: write Dynamic<Show>.
E1023
Dynamic<%s> needs Self as the first parameter of every function of %s, and %s.%s does not take it first
Dynamic<%s> needs Self only as the first parameter of every function of %s, and %s.%s names it elsewhere
A call through a Dynamic<Trait> passes the Dynamic where the trait writes Self, and the table of the stored type does the rest. That works only when every function of the trait takes Self as its first parameter, once and not inside another type, and mentions Self nowhere else, the result included. Equatable and Ordered take two values, and Shape.fromValue returns Self.
Example: trait Drawable { function draw(value: Self): string } can be used as Dynamic<Drawable>.
E1024
Dynamic has no function %s; Dynamic.of(value) is its only function
Dynamic.of takes one value
Dynamic.of needs an expected Dynamic<Trait> type; annotate it, as in `const item: Dynamic<Show> = Dynamic.of(value)`
Dynamic.of(value) takes the trait from the expected type: an annotation, a parameter type, a field type or a result type. It takes one value and is the only function of Dynamic.
Example: const item: Dynamic<Show> = Dynamic.of(42).
E1025
%s.%s takes a mutable Self, and a Dynamic<%s> cannot be passed to it: its value is shared by every copy
Every copy of a Dynamic shares one stored value, so a trait function that takes mutable value: Self cannot be called through a Dynamic: the change would reach the other copies.
Example: call the function on the concrete value before wrapping it with Dynamic.of.
E1030
retired: this error is no longer reported
E1031
retired: this error is no longer reported
E1032
retired: this error is no longer reported
E1033
retired: this error is no longer reported
E1034
retired: this error is no longer reported
E1035
retired: this error is no longer reported
E1050
@const function %s %s; an @const function takes and returns numbers, bool, char, string, bytes, Array, Map, FixedArray, Option, Result, tuples, and structs, enums and distinct types made of these
The compiler runs an @const function while it compiles and writes the result into the C, so its parameters and result hold only values the compiler can build and write: numbers, bool, char, string, bytes, Array, Map, FixedArray, Option, Result, tuples, and structs, enums and distinct types made of these. A function value, Cell, Ptr, Shared, a generator, a trait-constrained type parameter or an effect parameter has no compile-time value.
Fix: remove @const, or change the signature.
E1051
@const function %s declares `uses %s`; an @const function may use only alloc
@const function %s uses %s%s; an @const function may use only alloc
An @const function runs inside the compiler, where nothing outside it can observe what it does. It may allocate, and nothing else: no io and no unsafe code.
Fix: move the effect out of the function, or remove @const.
E1052
@const function %s %s; an @const function calls only @const functions, constructors and the std functions of %s that take no function
constant %s cannot be computed while compiling: %s
An @const function calls other @const functions, constructors and the std functions of std/string, std/array, std/map, std/int, std/float, std/range, std/char, std/option, std/result, std/regex, std/math, std/bytes, std/fixedarray, std/f32 and the sized number modules that take no function. It cannot use an arrow function, call through a function value or run a user implement block (through ==, a map key or a direct call).
Fix: mark the called function @const, compute the value another way, or remove @const.
E1053
constant %s panicked while the compiler computed it: %s
The compiler computes a constant that calls an @const function while it compiles. A panic, a failed assert, an index out of range or a std function that would panic stops the computation, and the error shows the chain of calls from the constant to where it stopped.
Fix: change the arguments or the function so it does not panic.
E1054
constant %s needs more than %s evaluation steps; %s
A constant may take 10 million evaluation steps (one per expression, statement and loop turn, plus one per 8 bytes or elements a std call goes through), so a mistake such as an endless loop cannot hang the compiler.
Fix: compute a table this large at run time in a function, or generate a source file; for Regexes.checked, compile the pattern at run time with Regexes.compile.
E1055
constant %s needs more than 64 MiB of values (%s); %s
The values a constant builds while it is computed may take 64 MiB, counted as 8 bytes per number, element, field and entry, string lengths rounded up to 8, and 16 per array and map; copy(...) and storing a value read from a place count its outer level again. A std call whose result would pass the limit is stopped before it runs.
Fix: compute a table this large at run time in a function, or generate a source file; for Regexes.checked, compile the pattern at run time with Regexes.compile.
E1056
constant %s makes more than %s nested calls; a self-call in tail position runs as a loop and does not count
constant %s holds a value nested more than %s levels deep; the compiler writes a computed value only up to that depth
constant %s nests calls, blocks and expressions more than %s deep; a self-call in tail position runs as a loop and does not count
A constant may make 1000 nested calls while it is computed, nest calls, blocks, loops and expressions 5000 deep, and build values nested 1000 levels deep, which keeps the compiler stack safe. A function that calls itself as its last step (return f(...)) runs as a loop and does not count.
Fix: write the recursion as a loop or as a tail call.
E1057
constant %s is read by an @const function while it is computed, so it is defined in terms of itself
An @const function may read top-level constants. A constant whose computation reads the constant itself has no value to start from.
Fix: break the cycle, for example by passing the value as an argument.
E1100 to E1199: Concurrency
E1100
await is allowed only in an async function, an async arrow or an async block, not %s
await waits for a task, so it can stand only where the body is itself a task: an async function, an async arrow or an async block. A function* body and an arrow that is not async are bodies of their own, also inside an async body.
Fix: make the function or arrow async, or pass the handle on and await it in an async body.
E1102
await takes an Async<T>, found %s; only the handle of a task can be awaited
await takes the handle of a task, an Async<T>, and gives its value.
Fix: await the call that returns the handle, or use the value without await.
E1103
this Async handle is not used; await it, keep it, pass it on, or let the task run with Async.detach(handle)
A call of an async function, an async arrow or an async { ... } block starts a task and gives its handle. A handle that nobody uses hides a task that keeps running; const _ = does not let it go.
Fix: await the handle, keep it in a name, pass it on, or call Async.detach(handle) to let the task run with nobody waiting.
E1104
async function %s cannot take a mutable parameter %s; its task outlives the call
A task outlives the call that starts it, so it cannot keep a pointer into the caller's variable.
Fix: take the value as a plain parameter and return the new value from the task.
E1105
`for await (mutable ...)` is not allowed: a stream's values are not elements to change in place; write `for await (const x of stream)`
`for (mutable ...)` is not allowed in an async body; change the elements through an index, as in `items[index].field = value`
A for (mutable ...) loop holds a pointer to the element it changes, which cannot be kept in a task frame across an await. for await (mutable ...) is rejected too: the values of a stream are not elements of a place.
Fix: change the elements through an index; read a stream with for await (const x of stream).
E1106
cannot use == on %s: a task handle is shared by identity; await the handles and compare the values
cannot use == on %s: a stream is shared by identity; read the values and compare them
%s cannot be a map key: %s
A handle is an identity type: copies share one task, so == and a map key would compare tasks, not values.
Fix: await the handles and compare or key by the values.
E1107
retired: async generators are compiled now, so this error is no longer reported
retired: async function* declares an async generator now (D110), so this error is no longer reported.
E1108
async must be followed by function, an arrow function or a block, found %s
async starts an async function, an async arrow or an async block.
Fix: write async function, async (x) => ... or async { ... }.
E1109
Async takes one type argument, the value of the task
Async<T> takes the type of the task's value as its one type argument.
Fix: write Async<T>, with Async<void> for a task that gives no value.
E1110
an async arrow or block cannot capture %s, which is %s: the task copies its captures when it starts; keep state that changes in a Cell from std/cell
an async arrow or block cannot change captured %s: the task copies its captures when it starts; keep state that changes in a Cell from std/cell
An async arrow or block copies what it captures when its task starts, so a let, a mutable parameter or a captured value it changes would no longer be shared with the code around it.
Fix: keep state that changes in a Cell from std/cell, or pass the value in and return the new one.
E1111
parameter %s of async function %s has a function type, so it must be `escaping`: the task outlives the call
An async function keeps its parameters in its task, which outlives the call, so a function parameter must be one that may be stored.
Fix: declare the parameter as escaping.
E1112
async generator %s must declare its return type as AsyncGenerator<T>, not Generator<T>; write AsyncGenerator<T>
async generator %s must declare its return type as AsyncGenerator<T>
An async function* produces a stream of values that may wait between them, read with Async.next or for await. Its result names that stream, with the effects of the body on it.
Fix: write the result as AsyncGenerator<T>, as in async function* lines(): AsyncGenerator<string> uses io.
E1113
generator %s cannot return AsyncGenerator<T>, which needs an async body; declare it as `async function* %s`
An AsyncGenerator<T> body may wait between its values, so only an async generator can return one from its own body. A plain or async function may still return a stream it got elsewhere.
Fix: write async function*, or return a Generator<T>.
E1114
AsyncGenerator takes one type argument, the type of the values it yields
AsyncGenerator<T> takes the type of the values the stream yields as its one type argument.
Fix: write AsyncGenerator<T>.
E1115
`const %s = yield value` needs a coroutine, and an async generator has no input; write `yield value`
An async generator yields values to its readers and gets nothing back: there is no async coroutine.
Fix: write yield value as a statement, and pass input to the stream through its arguments or a Cell.
E1116
yield* in an async generator needs a %s, found %s; write `for (const x of g) { yield x }`
yield* in an async generator needs a %s, found %s
yield* in an async generator passes on every value of another AsyncGenerator<T> with the same T, one per step of the outer stream.
Fix: delegate to an AsyncGenerator<T>; for a Generator<T>, write for (const x of g) { yield x }.
E1122
for await is allowed only in an async function, an async arrow, an async block or an async generator, not %s
for await waits for each value of a stream, so it can stand only where the body is itself a task: an async function, an async arrow, an async block or an async generator. A function* body and an arrow that is not async are bodies of their own, also inside an async body.
Fix: make the function or arrow async, or read the stream with Async.next in an async body.
E1123
for await reads an AsyncGenerator<T>, found %s; read a Generator<T> with `for (const x of g)`, which works in an async body
for await reads an AsyncGenerator<T>, found %s; loop with `for (const handle of handles)` and `await handle` in the body
for await reads an AsyncGenerator<T>, found %s
for await reads an AsyncGenerator<T>, the stream an async function* gives, one step at a time.
Fix: for a Generator<T> or an array, write for (const x of items), which works in an async body; for an Array<Async<T>>, loop over the handles and await each one.
E1124
for ... of cannot read %s, whose values may wait; write `for await (const x of stream)` in an async body
The values of an AsyncGenerator<T> may wait, so a plain for ... of cannot read them.
Fix: write for await (const x of stream) in an async body, or read one step with await Async.next(stream).
E1150
%s cannot take an Async<void>: type parameter %s would be void outside Async<%s>, and a task with no value gives none
An Async<void> handle binds the type parameter of its Async<T> to void. A generic function whose signature also uses that parameter as a value, such as Async.peek (Option<T>), Async.all (Array<T>) or Async.race (Option<T>), would need a void value, which does not exist.
Fix: await the handles one by one, or give the task a value, such as a bool.
E1190
%s: %s is not Sendable%s
A value that crosses to another thread (a capture or the result of a thread function, the items of Parallel.map) must be Sendable. Sendable is automatic: a type is Sendable when nothing in it, at any depth, is a function, a Dynamic, a Ptr, a Cell, an Async, a generator or coroutine, a Scope, a Thread or a socket handle. These hold state that one thread changes in place without a lock.
Fix: share changing state through Shared from std/shared, send plain data, and declare a type parameter that crosses as <T: Sendable>.
E1191
%s holds a Scope; a Scope can be passed to a function, but not stored in a field, element, tuple or constructor
a function cannot return a Scope (%s): every thread of a Scope ends when its Thread.scope returns
a generator, coroutine, stream or task cannot hold a Scope (%s): it can run after its Thread.scope returns
an escaping closure or a task cannot capture Scope %q; pass the Scope to a function as a parameter, or open a new Thread.scope inside the closure
A Scope joins its threads when its Thread.scope returns, so it must not outlive that call. It can be passed to functions, but not stored in a field, element, tuple or constructor, returned, captured by an escaping closure such as a thread function, or kept in the frame of a generator, coroutine, stream or task (a parameter or a capture), which can run after Thread.scope returns.
Fix: pass the Scope as a parameter to the function that starts threads, or open a new Thread.scope where it is needed.
E1192
Thread.start takes a plain function; use Thread.startAsync to run an async function on a thread
Thread.start calls its function and keeps what it returns. An async function returns an Async handle, which belongs to the event loop of the thread that made it. Thread.startAsync runs the task on the new thread's own event loop and keeps the value the task gives.
Fix: write Thread.startAsync(scope, async () => work()), or pass a plain function to Thread.start.
E1193
a thread function must be an arrow function written at the call or the name of a top-level function, so its captures can be checked
The checker must see what a thread function captures, and a function value does not show its captures in its type. So the function passed to Thread.start or Parallel.map is an arrow function written at the call or the name of a top-level function.
Fix: write the arrow at the call, as in Thread.start(scope, () => work(input)).
E1194
cannot write `%s Sendable`: the compiler implements Sendable for every type whose parts can cross a thread
Sendable is only automatic: the compiler implements it for every type whose parts can cross a thread, so a type cannot list, derive or implement it.
Fix: remove the implement Sendable, implements Sendable or derives Sendable.
E1195
cannot use == on %s: %s is shared by identity; compare the values it gives
%s cannot be a map key: %s
A Thread, a Scope, a Sender, a Receiver, a Shared or an Atomic is a handle shared by identity, so ==, != and map keys on it are errors, as for a Cell and an Async.
Fix: compare the values the handles give, for example the results of Thread.join or Shared.get.
E1200 to E1299: Types and parameters: templates, defaults, refinements, effect lists, SIMD, ranges
E1200
a template after an expression is a tagged template, and only a name or a dotted name can be its tag
a tag takes no type arguments; the tag's parameters give its type
A template right after a name is a tagged template: taga${x}b`` calls tag(["a", "b"], [x]). Only a name or a dotted name can be the tag, so the function called is named where it is used.
Fix: put the tag in a constant first (const tag = make(), then tag...``), or write a space-free name before the template.
E1201
a tag must be a function of (Array<string> or Template.Raw, Array<T>) with no mutable parameter, found %s
A tag is a function of two parameters: the parts, Array<string> (escapes decoded) or Template.Raw from std/template (the source text), and the values, Array<T>. Neither parameter can be mutable.
Fix: give the tag that signature, for example function tag(parts: Array<string>, values: Array<string>): string.
E1202
value %s of the tagged template is %s, but the tag takes values of type %s; convert it inside the ${}
value %s of the tagged template is void; a value must have the tag's value type
Every ${} value of a tagged template has the tag's value type T, the element type of its second parameter. A generic tag takes T from the first value.
Fix: convert the value inside the ${}, for example ${Int.toString(count)}.
E1203
a template at the start of a line is not tagged by the name that ends the line before; join the lines to tag it
A line break ends the statement, so a template at the start of a line is not tagged by the name at the end of the line before, as it would be in TypeScript.
Fix: write the tag and the template on one line, const x = taga``, or remove the template.
E1210
a parameter without a default cannot follow one with a default; give %q a default or move it before %q
E1211
a mutable parameter cannot have a default
E1212
a parameter default must be a constant
E1213
an arrow function parameter cannot have a default
a function type cannot have parameter defaults
E1214
a trait function cannot have parameter defaults
E1215
a function of an extern block cannot have parameter defaults
E1216
optional parameters are written with a default; write %q
an arrow function parameter cannot be optional; write %q
E1220
a distinct type's `requires` needs a pattern here, found %s
a distinct type takes one `requires` list; join its patterns with `&&`
`implements` and `derives` come before `requires` on a distinct type
E1221
distinct type %s cannot have a requires list: its base %s is not an integer type or string
E1222
%s refines string, so its patterns are string literals; `%s` compares integers
the bound of `%s` does not fit %s's base %s
the bound of `%s` must be an integer constant: a literal or a top-level const
the literal %s cannot be proven for %s's base %s; the prover keeps integers as int and cannot prove 2^63 - 1, -(2^63 - 1) or a u64 from 2^63 up
the literal %s is not a value of %s's base %s
a refinement pattern is a comparison, a literal or alternatives of them, found %s
E1223
%s does not satisfy %s (%s)
%s.from needs %s to satisfy %s; check it first or call %s.check
E1240
a type's `uses` list takes one effect, or several in parentheses: `uses (%s, %s)`
In a type, uses takes one effect, or a comma list in parentheses: () => int uses io, Generator<int> uses (io, alloc). A , after the one effect ends the type, so the type can stand in a list of types or parameters. A function's own list, after its result type, is a bare comma list.
Fix: put the type's effects in parentheses, Generator<string> uses (io, alloc). A function that makes a generator writes its own list after it: (): Generator<string> uses (io, alloc) uses alloc.
E1241
`%s` is an effect, not a type
`%s` is an effect, not a type; a type takes several effects in parentheses: write `uses (%s)`
io, alloc, unsafe and effect variables name effects, which only a uses list holds; they are not types. In a list of types such as Map<Generator<int> uses io, alloc>, the , ends the generator's one effect, so alloc stands where a type belongs.
Fix: write the effects in parentheses, Map<Generator<int> uses (io, alloc), int>, or move the name into a uses list.
E1242
`%s` is listed twice in this `uses` list
A uses list names each effect once, in a type and in a function's own list.
Fix: delete the repeated name: uses (io, io) in a type and uses io, io on a function both become uses io.
E1250
%s is not defined on %s; compare the lanes with %s
%s is not defined on %s: no SIMD instruction divides integer lanes; read the lanes with v[i] and divide them one at a time
%s is not defined on %s; shift the lanes with %s
%s is not defined on %s, whose lanes are floats; it takes integer vectors
E1251
%s needs two vectors of the same type, found %s and %s
%s needs two vectors of the same type, found %s and %s; make a vector of the scalar with Simd.splat(...)
E1252
a lane of %s cannot be assigned, since a vector is a value; write `v = Simd.withLane(v, i, x)`
E1253
%s needs %d lanes, found %d
E1254
%s takes its vector type from where the result goes or from a type argument, as in `const ones: F32x4 = Simd.splat(1.0)` or `Simd.splat<F32x4>(1.0)`
%s takes its vector type from where the result goes or from a type argument, as in `const lanes: Option<F32x8> = Simd.load(items, 0)` or `Simd.load<F32x8>(items, 0)`
E1255
%s has no vector type: a vector holds 16 or 32 bytes of i8 to u64, f32 or f64 lanes
%s takes a FixedArray of known length, found %s
E1256
%s takes a vector, found %s
E1260
the lanes of %s are a list literal of constants, one per lane, as in `Simd.shuffle(v, [3, 2, 1, 0])`
%s takes %d lanes for %s, found %d
lane %d is out of range for %s, whose lanes are 0 to %d
a lane of %s must be a constant, as in `Simd.shuffle(v, [3, 2, 1, 0])`
E1261
%s does not take %s, whose lanes are floats; it takes integer vectors
%s does not take %s, which is unsigned; it takes signed and float vectors
%s takes the mask %s for %s, found %s
%s writes %s into an Array<%s>, found %s
E1270
the step of Ranges.stepped is 0, so the range is always empty; use a step other than 0
E1300 to E1399: Standard library modules for tools
E1360
%s can only be the value of a top-level const; use %s
Regexes.checked compiles its pattern while the compiler runs, so a bad pattern is a compile error (E1053) instead of a panic. That works only where the compiler computes the value: the value of a top-level const. Anywhere else, including a function body or a use as a function value, the call would run in the program and could panic.
Fix: move the call into a top-level const, or call Regexes.compile and handle its RegexError.
E1400 to E1499: Channels, Shared and Atomic
E1410
the callback of %s cannot be async: it runs while the lock is held, and a task must not suspend there
Shared.update and Shared.read hold the lock while their callback runs. An async callback would give an Async whose task runs later, after the lock is released, or suspend while other threads wait for the lock.
Fix: pass a plain function, and await the work before or after the call.
E1411
Atomic<%s> is not allowed: an Atomic holds bool or an integer type up to 64 bits; keep other values in a Shared from std/shared
An Atomic<T> uses the processor's atomic operations, which work on bool and the integer types up to 64 bits (int, i8 to i32, u8 to u64). A type parameter is not allowed either, since no bound says "an integer type".
Fix: use an integer type, or keep the value in a Shared from std/shared.
E1412
Atomic.add needs an integer type, found Atomic<bool>; use Atomic.store or Atomic.compareExchange
Atomic.add adds to an integer. An Atomic<bool> has no sum.
Fix: use Atomic.store, Atomic.exchange or Atomic.compareExchange to change a flag.
E1500 to E1599: Unreachable statements and unused let
E1500
this statement is unreachable: the statement before it always leaves the block
A statement after return, break, continue, a call to panic or Process.exit, an if and else that both leave, a match whose arms all leave, or a while (true) loop without a break never runs.
Fix: delete the statements from the first dead one to the end of the block, or move the code before the statement that leaves.
E1510
%q is never reassigned; declare it with `const`
A let tells the reader that the name gets a new value later. A name that is never assigned, never changed with += or ++, and never has a field, an element or a mutable argument written is a const.
Fix: write const instead of let.
E1600 to E1699: Build targets
E1600
unknown target %s; the targets are %s
E1601
-sanitize cannot build for %s: sanitizer runtimes do not cross-link; build without -sanitize