규칙 12.7
이 페이지에서

규칙 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. 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 Ref<T> parameter is its T to the editor’s checker, as the compiler reads it in the body, and its hover is the compiler’s: the parameter written Ref<T> and the place it names (Rule 8.25).

규칙 본문과 그 아래 항목은 설계 문서에 적힌 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.

근거

an editor that accepts what the compiler refuses, or the reverse, is a second surface.

출처

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.

검증 방식

테스트로 확인합니다. 테스트나 게이트 스크립트, CI 워크플로가 이 규칙을 가리키고, 아래 파일 가운데 하나라도 규칙을 더는 가리키지 않으면 추적 검사가 실패합니다.

컴파일러가 이 규칙을 적용하는 곳을 규칙이 직접 적은 내용입니다.

  • src/language-service/ambient.test.ts (among it accepts an unsigned coordinate on textureLoad and textureStore, the vec2u coordinate WGSL and the compiler take, and every example with no diagnostic) and surface-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.test.ts (the Math object the ambient library declares is the compiler's table, #186), which reads interface MathObject with the parser and holds it to the compiler’s Math table (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, as compile() accepts or refuses it, at every count of arguments from none to four; Math.random is the one exclusion, pinned with #181, since its declaration takes no argument and the compiler takes one seed. The same file reads log10, log1p, expm1, cbrt, hypot and atan(y, x) (Rule 9.2) in both halves on one source each, clean in the editor and in tshc check and 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.test.ts (an operation other than arithmetic loses a vector type the same way) and src/language-service/projection.test.ts, over every operator TypeScript types as a number or a boolean (the ERASING_OPERATORS table 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 under examples/ and journeys/ 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 of core.def and 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’s length is the u32 the 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 two bools, 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 the bool the compiler gives it (projection.ts), where it kept TS2447 and the TS2322, TS2345 or TS2769 of the number TypeScript 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 Ref<T> parameter;
  • 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, through authorTypeText (B, N.P for 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 that new says of the class it builds, are outside this test.

커밋 c66579bf에서 이 규칙을 확인하는 파일입니다. 파일마다 규칙을 처음 가리키는 줄로 연결했습니다.

설명하는 절

커밋 c66579bf의 표면 문서에서 이 규칙을 설명하는 절입니다.

함께 보기

소스

커밋 c66579bf의 규칙 원문:

이 페이지 편집 문제 보고