Reserved built-in namespace identifiers
These names are reserved for compiler-intrinsic namespaces. They cannot be used as local variable or parameter names, even when the corresponding namespace is unused and has not been imported. Use different names for your own bindings and declarations.
cfg compress crypto db fs
gpu gui hash http httpserver
json math multipart native ratelimit
sse syn sys tcp websocket
xmljson is the exception: it may name a variable or parameter (fn parse(string json)),
and inside that scope the name is the variable and the json namespace is not
reachable (call json.parse<T>(...) in a scope where no local is called json).
It also remains valid as a struct field name (type Msg { string json }).
For example, GpuBuffer db = ... produces 'db' is a reserved identifier.
Use weightsBuffer or outputBuffer for a GPU buffer, and conn for a
database connection.
This list matches RESERVED_NAMES in the analyser.
It lists reserved identifiers, rather than every available intrinsic:
regex is a built-in namespace but is not currently in that reserved-name
registry. Avoid shadowing built-ins even when a spelling is accepted.
Language keywords and type spellings are reserved separately. For example,
fn num(...), fn int(...), and fn str(...) are invalid because those
names denote types. See primitive types and
#ai aliases for the type names and mode-specific aliases.
Contextual and reserved keywords
fromis a keyword only inside animportstatement (import x from "p",import { a } from "p",import * from "p"). Everywhere else it is an ordinary identifier: a variable, parameter, struct field, struct-literal key or member (int from = 0,{ from: 1, to: 5 },range.from).longstays reserved, like the other primitive type spellings (int,uint,float,decimal,byte,bool,char,string,num,any,var,void,null).test,matchandnsare keywords everywhere, not only where they start a test block, amatch (x) { }or a namespace:bool match = trueis a parse error (reported as an unexpected token), and so isint test = 1. A type name can begin a declaration (long total = 0), so readinglongas a name there would makelong xambiguous; name a variabletotalorcountinstead. Field names are not an exception either:type T { long long }is rejected.meis the receiver inside a method written in a type body (and@nameis its fieldname, exactlyme.name). It cannot be declared as a variable, parameter, field, function or type name anywhere, and outside a method bothmeand@nameare errors.thisis an ordinary identifier; inside a method the “undefined variable” error for it says to writemeor@.- The remaining language keywords (
fn,if,for,return,type,ns, …) are reserved as variable names, but most can be used as struct field names and struct-literal keys (type Event { string type }).
Names of C library functions (open, read, write, close, time, exit,
strlen, …) are not reserved: a top-level function may use them. Program and
test binaries give user functions internal linkage, and a name the compiler itself
declares from libc (exit, strlen, malloc, …) gets a distinct symbol, so a
user function never replaces the C function of the same name.