Rule 9.9
On this page

Rule 9.9

Chapter 9, Built-in functions and the TypeShade extensions Test

A WGSL built-in function, an overload of one, or a §9.3 name must not be authorable when an ECMAScript spelling the compiler supports carries every case it accepts with the same meaning (Rule 1.4). A call or a read of a removed name must be refused in one sentence that names the ECMAScript spelling: arrayLength was removed: write xs.length. A name stays when a case only it carries is the reason, and the reason is recorded: TAU (neither ECMAScript nor WGSL has it), select (the bool-vector mask), the WGSL math names (the vector forms), any(v) and all(v) on a bool or a bool vector, mod, fill, zip, discard and random.

The rule text and the parts under it are the compiler's own English, as the design document writes them.

Rationale

a second spelling of a meaning is a thing to learn and not a thing to use (Rule 1.4). The test asks one question of each name: does an ECMAScript spelling carry every case this name accepts, with the same meaning? xs.length carries every case of arrayLength, Math.log10 of log10, xs.reduce((a, b) => a + b) of sum (the same unrolled additions in the same order), xs.some(p) and xs.every(p) of the any and all folds, !xs.some(p) of none, and ** of pow over a scalar and a vector alike. A removed program stops compiling with its fix in the sentence (Rule 12.1), which Rule 13.10 allows before 1.0.0, since it does not compute something else.

Derives from

Rule 1.4; changes/0112-one-spelling.md (sections 1 to 3), which measured each row on both halves; the roadmap’s first rule, “ordinary TypeScript first”.

How it is verified

Checked by a test. A test, a gate script or a CI workflow names this rule, and the traceability check fails when a file listed below stops naming it.

Where the rule says the compiler enforces it:

  • src/compiler/ts/removed-names.test.ts, which reads each removed spelling and its replacement on both halves, compile() and the language service’s getDiagnostics, on one source: the code and the sentence of the refusal (TS8004 for a call, TS8022 for a read of a constant, TS8019 for the any and all folds), and the same emit and the same CPU result from the replacement;
  • the same file (a removed name is not declared by the ambient library), which fails on a declaration of one in SHADE_DTS, and surface-names.test.ts, which holds every declared name to WGSL, ECMAScript or the §9.3 table;
  • review (Rule 13.1) for a new name, which asks the question above before the row or the declaration is added.

The files that verify it at commit af54ddad5, each at the first line that names the rule:

Error codes that enforce it

The diagnostic codes the rule names under Enforced by, or whose registry text names the rule:

TS8004 UNKNOWN_FN
A call to a function the file neither declares nor imports, or to a builtin the language removed because ECMAScript spells it, such as arrayLength(xs), whose message names xs.length (Rule 9.9).
TS8019 ARITY_MISMATCH
A wrong number of arguments, elements or fields at a call or a constructor.
TS8022 UNKNOWN_NAME
A reference to a name that TypeShade cannot resolve and that is not a function call (UNKNOWN_FN) or a type name (UNKNOWN_TYPE). A name that the library declares for TypeScript's own use (Object, Math, Symbol), or that the file declares as an enum, a namespace, a class or a type, and that is read as a value, says what it is.

See also

Source

The rule at commit af54ddad5:

Edit this page Report a problem