규칙 2.2
이 페이지에서

규칙 2.2

2장, 표면 이름의 출처 테스트

A compiler-internal name (§2.1) must not be authorable. It must not be declared in the ambient library, as a name, as a signature or an overload of an allowed name, or as a member of an allowed type. It must not be given a row of §9.3, under its own id or under any other spelling of the same thing.

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

근거

an internal helper is a contract between two passes, and an author who can write it can also write it wrong, with no specification to say what wrong means.

출처

the same section of PR #166, written on the f64FromParts case (§2.4).

검증 방식

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

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

  • surface-names.test.ts (no pre-emit intrinsic id is declared or listed), which asserts that every id of PRE_EMIT_INTRINSICS other than the type name f64 is neither declared in SHADE_DTS nor a row of TYPESHADE_EXTENSIONS;
  • the same test (reports an internal helper by name when one reaches the surface), for the sentence a stray declaration gets;
  • the same test (the front end resolves no pre-emit id as a builtin), for the call route, since resolveMathFn in src/compiler/ts/math-alias.ts resolves an alias only when isKnownIntrinsic accepts its id, exempting f32, atan2, and mod, none of which is pre-emit, so f64Parts(x) in a shader is TS8004 Unknown function;
  • the same test’s first case, which catches a generated backend name that is declared, as a stray;
  • the same test (the f64 family declares only the constructor forms WGSL gives the type it stands in for), for the overload route, which pins every declared signature of f64 to one argument and every signature of vec2f64, vec3f64, and vec4f64 to WGSL’s vector constructor forms (a splat, N components, or a narrower f64 vector plus components);
  • that same case, which reports f64(hi: f32, lo: f32) appended to the library;
  • the same test (the compiler refuses a second argument to f64), for the call route of the same overload, TS8019 f64() expects 1 argument.;
  • the call route of the IR builder’s .swizzle(), which no call reaches by its name since proposal 0008: v.swizzle("yxz") is TS8022, a member the vector does not have, which names the member it is written as, v.yxz, pinned by src/compiler/ts/swizzle-random.test.ts;
  • review under §2.1’s definition (Rule 9.8), since a name that denotes an internal representation under an id outside PRE_EMIT_INTRINSICS passes every case of the test once it has a row.

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

설명하는 절

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

적용하는 오류 코드

규칙이 Enforced by 항목에서 가리키는 진단 코드와, 레지스트리 설명에서 이 규칙을 가리키는 진단 코드입니다.

TS8004 UNKNOWN_FN
파일이 선언하지도 가져오지도 않은 함수를 부릅니다.
TS8019 ARITY_MISMATCH
Wrong number of arguments, elements, or fields at a call or constructor site.
TS8022 UNKNOWN_NAME
Reference to a name TypeShade cannot resolve (identifier, struct field, or struct shape) that is not a function call (UNKNOWN_FN) or a type name (UNKNOWN_TYPE), in a body a call lowers or in one no call lowers; a name the library declares for TypeScript's own use (Object, Math, Symbol), or the file declares as an enum, a namespace, a class or a type, read as a value says what it is.

함께 보기

소스

커밋 c66579bf의 규칙 원문:

이 페이지 편집 문제 보고