규칙 12.7
12장, 진단 테스트
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.
Nullable reads replace TypeScript TS18047, TS18049, TS2531 and TS2533 with the compiler’s TS8003 at the same source location. For a null-only result, a bare return or fall-through yields null (0099 D3); the editor suppresses TS2322 only on that bare return and TS2366 on that result. Hover preserves the logical spelling T | null or T | null | undefined (change 0098).
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.
A constant of no fixed type (Rule 5.1) has no one type, so its hover must be the language’s own words at its declaration, const K = 3 (i32, u32, f32 or f64 where it is read), or (f32 or f64 where it is read) for a float-written one, and at a read the type the compiler gave that read, const K: u32 in vi * K (change 0134 item 4, decision Q3); a read whose lowerings give it two types keeps the words.
An object parameter that its function writes is its written type to the editor’s checker, as the compiler reads it in the body, and its hover is the compiler’s: the parameter with its type, and a paragraph that says it is the caller’s object (Rule 8.25). A read before an assignment is the compiler’s to report (TS8075, Rule 7.6), in TypeScript’s TS2454 place, where the editor shows the compiler’s sentence.
A read of an optional value that nothing narrowed is the compiler’s to report (TS8003, Rule 7.10), in TypeScript’s TS18048, TS2532, TS2538, TS2322 or TS2345 place, and the editor shows the compiler’s sentence there and drops TypeScript’s; the compiler’s narrowing must not refuse what TypeScript’s narrowing accepts, except the recorded forms of Rule 7.2, and an optional’s hover is f32 | undefined, as TypeScript spells it (change 0088).
규칙 본문과 그 아래 항목은 설계 문서에 적힌 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.
근거
an editor that accepts what the compiler refuses, or the reverse, is a second surface.
출처
the imports from the compiler of the files of src/language-service/ambient/; #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.
검증 방식
테스트로 확인합니다. 테스트나 게이트 스크립트, CI 워크플로가 이 규칙을 가리키고, 아래 파일 가운데 하나라도 규칙을 더는 가리키지 않으면 추적 검사가 실패합니다.
컴파일러가 이 규칙을 적용하는 곳을 규칙이 직접 적은 내용입니다.
src/language-service/ambient-texture-refusals.test.ts(among itaccepts an unsigned coordinate on textureLoad and textureStore, thevec2ucoordinate WGSL and the compiler take),src/language-service/ambient.test.ts(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/ambient-parity-math-object.test.ts(the Math object the ambient library declares is the compiler's table, #186), which readsinterface MathObjectwith the parser and holds it to the compiler’sMathtable (MATH_MEMBER_NAMES): each name is declared as the call or the value the compiler resolves it as, and each call is accepted or refused by TypeScript’s half, read unmerged, ascompile()accepts or refuses it, at every count of arguments from none to four;Math.randomis the one exclusion, pinned with #181, since its declaration takes no argument and the compiler takes one seed. The same file readslog10,log1p,expm1,cbrt,hypotandatan(y, x)(Rule 9.2) in both halves on one source each, clean in the editor and intshc checkand hovering as the signature the compiler’s count of arguments gives them, and a wrong count as the compiler’s one sentence (Rule 12.4);src/language-service/diagnostics-brand-tags.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-array-length.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-brand-tags.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/reference-parameters.test.ts, which reads every reference program and refusal in the editor as well as in the compiler, and hovers a parameter that its function writes as the caller’s object;src/compiler/ts/object-reference.test.ts, which reads each row of change 0142’s Table 1 that stage 1 implements in both halves on one source;src/compiler/ts/definite-assignment.test.ts, which holdsTS8075to TypeScript’s TS2454 reads;src/compiler/ts/optional-values.test.ts, which reads each narrowing form and each un-narrowed read of an optional value in both halves and hovers an optional asf32 | undefined; theSAME_MISTAKEpairs for TypeScript’s TS18048, TS2532 and TS2538 insrc/language-service/diagnostics/same-mistake.ts, and the hover’s optional spelling, which Rule 7.10 names (change 0088);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.src/language-service/abstract-const-hover.test.ts, which reads each constant of no fixed type in both halves and hovers its declaration in the language’s words and each read at the type the compiler gave it there: an integer, anf32, anf64, a conversion, a loop bound, a quotient, a function-local constant, a derived constant, a static field, a loop step, aswitchlabel, a read in a generic body (one a lookahead lowers first included), a read in a file that imports it, an alias at its import, a float-written constant folded to an integer, and a refused label.
커밋 af54ddad5에서 이 규칙을 확인하는 파일입니다. 파일마다 규칙을 처음 가리키는 줄로 연결했습니다.
-
src/compiler/ts/abstract-super.test.ts:1 -
src/compiler/ts/array-minmax-types.test.ts:1 -
src/compiler/ts/builtin-type-diagnostic.test.ts:1 -
src/compiler/ts/class-member-diagnostics.test.ts:1 -
src/compiler/ts/compute-stage-reachability.test.ts:1 -
src/compiler/ts/definite-assignment.test.ts:1 -
src/compiler/ts/diagnostic-removed.test.ts:1 -
src/compiler/ts/doc-snippets.test.ts:1 -
src/compiler/ts/field-initializer-range.test.ts:1 -
src/compiler/ts/host-failed-input.test.ts:3 -
src/compiler/ts/host-kernel-gl-length.test.ts:1 -
src/compiler/ts/index-bound.test.ts:1 -
src/compiler/ts/io-attribute-arguments.test.ts:1 -
src/compiler/ts/io-name-cascades.test.ts:1 -
src/compiler/ts/local-call-diagnostic-names.test.ts:1 -
src/compiler/ts/local-places.test.ts:1 -
src/compiler/ts/module-vars-atomic.test.ts:1 -
src/compiler/ts/number-types.test.ts:1 -
src/compiler/ts/numerics-removed.test.ts:1 -
src/compiler/ts/object-reference-removed-forms.test.ts:1 -
src/compiler/ts/object-reference-reviews.test.ts:1 -
src/compiler/ts/object-reference-unread.test.ts:1 -
src/compiler/ts/object-reference.test.ts:1 -
src/compiler/ts/optional-values-loose-null.test.ts:1 -
src/compiler/ts/optional-values.test.ts:1 -
src/compiler/ts/reference-parameters-editor.test.ts:1 -
src/compiler/ts/reference-parameters.test.ts:1 -
src/compiler/ts/reference-reads.test.ts:1 -
src/compiler/ts/second-name-copies.test.ts:1 -
src/compiler/ts/second-name.test.ts:1 -
src/compiler/ts/super-constructor-diagnostics.test.ts:2 -
src/compiler/ts/switch-validation.test.ts:1 -
src/compiler/ts/texture-multiple-samplers.test.ts:1 -
src/compiler/ts/type-spelling.test.ts:1 -
src/core/spec-conformance/coredef-overloads.test.ts:1 -
src/core/spec-conformance/surface-names.test.ts:52 -
src/language-service/abstract-const-hover.test.ts:1 -
src/language-service/ambient-matrix-index.test.ts:1 -
src/language-service/ambient-parity-math-object.test.ts:1 -
src/language-service/ambient-parity.test.ts:1 -
src/language-service/ambient-storage-access.test.ts:1 -
src/language-service/ambient-texture-lowering.test.ts:1 -
src/language-service/ambient-texture-refusals.test.ts:1 -
src/language-service/ambient-vector-math.test.ts:1 -
src/language-service/ambient.test.ts:1 -
src/language-service/compiled-output-diagnostics.test.ts:1 -
src/language-service/diagnostics-brand-tags.test.ts:2 -
src/language-service/diagnostics-glsl-hlsl-names.test.ts:2 -
src/language-service/diagnostics-module-variables.test.ts:2 -
src/language-service/diagnostics-one-mistake.test.ts:2 -
src/language-service/diagnostics-vector-arithmetic.test.ts:2 -
src/language-service/diagnostics.test.ts:2 -
src/language-service/diagnostics.ts:1 -
src/language-service/diagnostics/same-mistake.ts:1 -
src/language-service/editor-parity.test.ts:1 -
src/language-service/expression-parity.test.ts:1 -
src/language-service/generic-arity-diagnostics.test.ts:1 -
src/language-service/hover-array-length.test.ts:1 -
src/language-service/hover-docs-domains.test.ts:1 -
src/language-service/hover.test.ts:1 -
src/language-service/imported-symbol-hover-declarations.test.ts:1 -
src/language-service/imported-symbol-hover-names.test.ts:1 -
src/language-service/imported-symbol-hover-other-documents.test.ts:1 -
src/language-service/imported-symbol-hover-reviews.test.ts:1 -
src/language-service/imported-symbol-hover-structs.test.ts:1 -
src/language-service/imported-symbol-hover.test.ts:1 -
src/language-service/loop-control-diagnostics.test.ts:1 -
src/language-service/module-variable-diagnostics.test.ts:1 -
src/language-service/projection-returns-and-arrays.test.ts:1 -
src/language-service/projection.test.ts:1 -
src/language-service/projection.ts:1 -
src/language-service/projection/vector-type-arguments.test.ts:1
설명하는 절
커밋 af54ddad5의 언어 문서에서 이 규칙을 설명하는 절입니다.
- §3 Entries — stage attributes and explicit builtins
- §26 Classes with methods, a constructor and static functions
- §49 The editor and the compiler agree
- §54 Derivative uniformity: the control flow a sample may be reached under
- §77 The subgroup built-in functions:
subgroupAddand the twenty beside it - §78 A numerical contract:
numerics(["finite-math"], f)
적용하는 오류 코드
규칙이 Enforced by 항목에서 가리키는 진단 코드와, 레지스트리 설명에서 이 규칙을 가리키는 진단 코드입니다.
함께 보기
소스
커밋 af54ddad5의 규칙 원문:
docs/language-design.md:1764(설계 문서)reqs/rules/RULE-1207.md(추적 항목)