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
xml

json 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

  • from is a keyword only inside an import statement (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).
  • long stays reserved, like the other primitive type spellings (int, uint, float, decimal, byte, bool, char, string, num, any, var, void, null).
  • test, match and ns are keywords everywhere, not only where they start a test block, a match (x) { } or a namespace: bool match = true is a parse error (reported as an unexpected token), and so is int test = 1. A type name can begin a declaration (long total = 0), so reading long as a name there would make long x ambiguous; name a variable total or count instead. Field names are not an exception either: type T { long long } is rejected.
  • me is the receiver inside a method written in a type body (and @name is its field name, exactly me.name). It cannot be declared as a variable, parameter, field, function or type name anywhere, and outside a method both me and @name are errors. this is an ordinary identifier; inside a method the “undefined variable” error for it says to write me or @.
  • 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.