Rule 12.7
Chapter 12, Diagnostics Test
The language service and the compiler must name one vocabulary: the ambient library’s declarations are derived from the compiler’s own tables and never retyped, a builtin’s overloads from Tint’s core.def through the TypeShade overlay, and a program the compiler accepts must draw no error in the editor or in tshc check.
An expression’s type in the editor must be the compiler’s, except a call whose numeric arguments are all literals, which WGSL types as an abstract numeric and the editor as number.
The rule text and the parts under it are the compiler's own English, as the design document writes them.
Rationale
an editor that accepts what the compiler refuses, or the reverse, is a second surface.
Derives from
the head of src/language-service/ambient.ts; #157 for the remaining gaps; Tint’s core.def and proposal 0017 for the builtins, and for the abstract numeric the literal types TypeScript gives 0. and 0 alike.
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/language-service/ambient.test.ts(among itaccepts an unsigned coordinate on textureLoad and textureStore, thevec2ucoordinate WGSL and the compiler take, and every example with no diagnostic) andsurface-names.test.ts;src/language-service/editor-parity.test.ts, over every swizzle of every vector type and the vector index;src/language-service/diagnostics.test.ts(an operation other than arithmetic loses a vector type the same way) andsrc/language-service/projection.test.ts, over every operator TypeScript types as anumberor aboolean(theERASING_OPERATORStable the projection and the diagnostics filters share), used in place and through a local;src/compiler/ts/doc-snippets.test.ts, which checks each documentation snippet in the editor as well as in the compiler;src/language-service/expression-parity.test.ts, which compares the type the front end gives every property access, element access and call in every program underexamples/andjourneys/with the type the editor’s checker gives it, and fails on a first divergence its shrink-only table does not list (0015);src/core/spec-conformance/coredef-overloads.test.ts, which claims every row ofcore.defand holds every SUPPORTED one to both halves on a witness per instance (0017);src/language-service/hover.test.ts(an array's length is the type the compiler reads): a runtime-sized storage array’slengthis theu32the compiler reads from the buffer, and a sized one’s is its literal size;src/language-service/diagnostics.test.ts(the _ of a phony assignment is the compiler's to judge):_ = max(a, 1.)is clean in the editor, as it compiles, and_ = a + 1.reads as the compiler’s one refusal;src/language-service/diagnostics.test.ts(reads & and | on two scalar booleans as the bool the compiler reads):&and|on twobools, WGSL’s logical and and or that do not short-circuit, compile, and the editor drops TypeScript’s TS2447 on them and reads the result as theboolthe compiler gives it (projection.ts), where it kept TS2447 and the TS2322, TS2345 or TS2769 of thenumberTypeScript typed it as;^and the compound forms on a bool, which WGSL does not have, read as the compiler’s one refusal;src/compiler/ts/type-spelling.test.ts: a message the front end writes names the type of a value, a field, a parameter or a return, and a class its sentence is about as a whole (its declaration, its base, a literal or a method call of it, a struct two files declare), as the author writes it, throughauthorTypeText(B,N.Pfor a class in a namespace,Slot<f32>for an instance of a generic class,vec3u,mat3x3,array<vec3u, 4>), not by the compiler’s key or emitted name (struct:B,N_P,Slot_f32,vec3<u32>); each such spelling is a type the editor reads, and each remedy the test pins compiles when pasted. A sentence about one member of a class, and one thatnewsays of the class it builds, are outside this test.
The files that verify it at commit 26de7be8, each at the first line that names the rule:
-
src/compiler/ts/doc-snippets.test.ts:191 -
src/compiler/ts/type-spelling.test.ts:15 -
src/core/spec-conformance/coredef-overloads.test.ts:1 -
src/core/spec-conformance/surface-names.test.ts:52 -
src/language-service/ambient.test.ts:1 -
src/language-service/diagnostics.test.ts:2 -
src/language-service/editor-parity.test.ts:1 -
src/language-service/expression-parity.test.ts:1 -
src/language-service/hover.test.ts:358 -
src/language-service/projection.test.ts:1 -
src/language-service/projection.ts:37
Explained in
The sections of the surface document that explain this rule, at commit 26de7be8:
See also
- Rule 12.6 Test
- Rule 13.1 Review
- Design rules
- Error codes
Source
The rule at commit 26de7be8:
docs/language-design.md:1266(the design document)reqs/rules/RULE-1207.md(its traceability item)