NL1xxx: forbidden syntax
The 68 codes of band 1. Diagnostics says what a code promises and how a rule's fragment is matched.
NL1001
The message of an error contains:
… (it aborts rather than unwinding): return a `Result<T, E>` for a failure a caller should handle, or `panic(message)` to end the process
NL1002
The message of an error contains:
… (modules are resolved at compile time)
NL1003
The message of an error contains:
… (no dynamic property interception)
NL1004
The message of an error contains:
… (no event loop or promises)
Retired: (no event loop or promises), the tail of the Phase 0 refusals of await and async that async functions replaced; await outside an async function is NL2641 now (tests/cases/reject_await)
NL1005
The message of an error contains:
… (no interpreter at runtime)
NL1006
The message of an error contains:
… (no runtime metadata or class rewriting)
NL1007
The message of an error contains:
… (object layout is fixed at compile time)
NL1008
The message of an error contains:
…; use `null` with a `T | null` type
NL1009
The message of an error contains:
…; use `obj.name` (no dynamic property lookup)
NL1010
The message of an error contains:
`__proto__` access is forbidden in …
NL1011
The message of an error contains:
`__proto__` is forbidden in …
NL1012
The message of an error contains:
`.prototype` access is forbidden in …
NL1013
The message of an error contains:
`any` is forbidden in …
NL1014
The message of an error contains:
`arguments` is forbidden in …
NL1015
The message of an error contains:
`async` functions are forbidden in …
Retired: async functions are forbidden, the Phase 0 refusal async functions replaced; an async function is checked now, and its rules are NL1063 and NL2639-NL2655 (tests/cases/async_, tests/cases/reject_async_)
NL1016
The message of an error contains:
`bigint` literals are forbidden in …
NL1017
The message of an error contains:
`bigint` type is forbidden in …
NL1018
The message of an error contains:
`debugger` is forbidden in …
NL1019
The message of an error contains:
`declare global` is forbidden in …
NL1020
The message of an error contains:
`delete` is forbidden in …
NL1021
The message of an error contains:
`Function` constructor is forbidden in …
// NL1021: `Function(...)` called without `new` is refused by its own Phase 0 rule, not by the `new Function` one.
export const main = (): i32 => {
const s: string = Function("return 1");
return 0;
};
`Function` constructor is forbidden in Nish (no interpreter at runtime)
NL1022
The message of an error contains:
`Function` is forbidden in …
No program provokes it: shadowed by NL1005, which is the longer run of the same sentence
NL1023
The message of an error contains:
`Function` type is forbidden in …
NL1024
The message of an error contains:
`globalThis` is forbidden in …
NL1025
The message of an error contains:
`in` operator is forbidden in …
NL1026
The message of an error contains:
`instanceof` is forbidden in …
NL1027
The message of an error contains:
`namespace` and `module` blocks are forbidden in …
NL1028
The message of an error contains:
`new Function` is forbidden in …
NL1029
The message of an error contains:
`Reflect` is forbidden in …
NL1030
The message of an error contains:
`Symbol` is forbidden in …
NL1031
The message of an error contains:
`symbol` type is forbidden in …
NL1032
The message of an error contains:
`Symbol` type is forbidden in …
// NL1032: `Symbol` in a type position has a Phase 0 rule of its own, separate from `Symbol` as a value.
export const main = (): i32 => {
const s: Symbol = 1;
return 0;
};
`Symbol` type is forbidden in Nish (no symbol type)
NL1033
The message of an error contains:
`try`/`catch`/`finally` is forbidden in …
NL1034
The message of an error contains:
`typeof` is forbidden in …
NL1035
The message of an error contains:
`unknown` is forbidden in …
NL1036
The message of an error contains:
`var` is forbidden; use `let` or `const`
NL1037
The message of an error contains:
`void` expressions are forbidden in …
NL1038
The message of an error contains:
`with` is forbidden in …
NL1039
The message of an error contains:
`yield` is forbidden in …
NL1040
The message of an error contains:
Comma expressions are forbidden in …
NL1041
The message of an error contains:
Computed property names are forbidden in …
// NL1041: An object literal's keys are names, because each key is a field slot fixed at compile time.
interface Point {
x: i32;
}
export const main = (): i32 => {
const k: string = "x";
const p: Point = { [k]: 1 };
return p.x;
};
Computed property names are forbidden in Nish (member names are fixed at compile time)
NL1042
The message of an error contains:
Element access requires a numeric index in …
NL1043
The message of an error contains:
Enum members must be numeric literals in …
NL1044
The message of an error contains:
Generators are forbidden in …
NL1045
The message of an error contains:
Generic type parameters are forbidden in …
Retired: Phase 0's blanket Generic type parameters are forbidden in before the refusal named the kind; the live ones are NL1054 and NL1055
NL1046
The message of an error contains:
Labeled statements are forbidden in …
NL1047
The message of an error contains:
Loose equality is forbidden; use === / !==…
NL1048
The message of an error contains:
Nullish coalescing `??` is forbidden in …
// NL1048: `??` whose left operand is neither a `T | null` nor a `Map.get` result.
export const main = (): i32 => {
const n: i32 = 3;
return n ?? 0;
};
Nullish coalescing `??` is forbidden in Nish (narrow with `!== null` instead)
NL1049
The message of an error contains:
Optional chaining `?.` is forbidden in …
NL1050
The message of an error contains:
Regular expression literals are forbidden in …
NL1051
The message of an error contains:
Type assertion to `any` is forbidden in …
NL1052
The message of an error contains:
Type assertion to `unknown` is forbidden in …
NL1053
The message of an error contains:
Union types other than `T | null` are forbidden in …
NL1054
The message of an error contains:
Generic type parameters are forbidden on a …
NL1055
The message of an error contains:
Generic type parameters are forbidden on a method in …
Retired: Phase 0's refusal of a type parameter on a method; generic methods compile now, and reject_generic_method now pins type arguments at a method call
NL1056
The message of an error contains:
… (it enumerates property names, and object layout is fixed at compile time); use `for...of`
NL1057
The message of an error contains:
… (an import names source this compiler reads, never a resource loaded at run time)
// NL1057: Import attributes describe how a host loads a resource, and an import here only ever names source.
import { one } from "./wordings_lib" with { type: "json" };
Import attributes (`with { ... }`) are forbidden in Nish (an import names source this compiler reads, never a resource loaded at run time)
NL1058
The message of an error contains:
… (an export is a declaration, and a declaration has a name; import it by that name)
// NL1058: An export is a declaration's name, so a module export name written as a string names nothing.
import { "one" as uno } from "./wordings_lib";
A module export name written as a string is forbidden in Nish (an export is a declaration, and a declaration has a name; import it by that name)
NL1059
The message of an error contains:
… (a module has no top-level code, so there is nothing to defer)
// NL1059: A module has no top-level code, so `import defer` has no evaluation to postpone.
import defer * as lib from "./wordings_lib";
`import defer` is forbidden in Nish (a module has no top-level code, so there is nothing to defer)
NL1060
The message of an error contains:
… (a module has no runtime object; resolve paths at compile time)
// NL1060: A module has no runtime object for `import.meta` to name; paths are resolved at compile time.
export const main = (): i32 => {
const url: string = import.meta.url;
return 0;
};
`import.meta` is forbidden in Nish (a module has no runtime object; resolve paths at compile time)
NL1061
The message of an error contains:
Object spread is forbidden in …
Retired: Object spread is forbidden in, the Phase 0 refusal object spread replaced when it became field copies; each form it still refuses has its own code now, NL2702-NL2710 and NL3055 (tests/cases/reject_object_spread*)
NL1062
The message of an error contains:
`?.` is allowed only in a chain that ends in `??`, whose default stands in when a link is `null`: write `a?.b ?? d`, or narrow with `!== null`
nl1062_chain_without_default.ts:
// NL1062: a `?.` chain that is not the left operand of `??`.
class Node {
value: i32 = 1;
}
export const f = (a: Node | null): i32 => a?.value;
`?.` is allowed only in a chain that ends in `??`, whose default stands in when a link is `null`: write `a?.b ?? d`, or narrow with `!== null`
NL1063
The message of an error contains:
Only a top-level function or an arrow may be `async`: a method, a field or a constructor cannot, because a task never keeps a `this`
NL1064
The message of an error contains:
…` has no initializer: every member of an enum whose members are strings is given its own string literal
nl1064_string_enum_no_initializer.ts:
// A string enum has no numbering to fall back on, so a member without an
// initializer is refused rather than given a number.
enum Role {
Admin = "admin",
Guest,
}
export const test = (): i32 => 0;
String enum member `Role.Guest` has no initializer: every member of an enum whose members are strings is given its own string literal
NL1065
The message of an error contains:
An enum member's value cannot be a template literal: write it as a plain string literal, which is fixed when the enum is declared
nl1065_enum_template_value.ts:
// A member's value is a plain string literal, fixed when the enum is declared.
enum Role {
Admin = `admin`,
}
export const test = (): i32 => 0;
An enum member's value cannot be a template literal: write it as a plain string literal, which is fixed when the enum is declared
NL1066
The message of an error contains:
A string enum member's value must be a string literal: a computed value is not supported, because the enum's strings are a table fixed when it is declared
nl1066_string_enum_computed.ts:
// A string enum's values are a table fixed at declaration, so a computed value
// is refused.
enum Role {
Admin = "admin",
Guest = "gu" + "est",
}
export const test = (): i32 => 0;
A string enum member's value must be a string literal: a computed value is not supported, because the enum's strings are a table fixed when it is declared
NL1067
The message of an error contains:
An element read cannot end a `?.` chain or be what a `?.` tests: past the end of the array JavaScript answers `undefined` and carries on, and the bounds check panics (test the index against `length`, or narrow the array with `!== null` and read the element into a `const`)
NL1068
The message of an error contains:
An optional call `f?.()` is not supported, with or without `--compat`: call `f()` directly, or narrow `f` with `!== null` first

