규칙 2.1
이 페이지에서

규칙 2.1

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

Every author-facing name must come from exactly one of three sources:

  • (a) WGSL, as the specification spells it: a built-in function, a predeclared type or type-generator including the predeclared vecNf/vecNi/vecNu aliases, an attribute reached as a decorator, a built-in value passed as a string, or an extension name;
  • (b) ECMAScript, as TypeScript spells it: a member of Math, a method of console, a method Array.prototype has, written on an array (surface §63), a literal, an operator, the declaration forms class, interface, enum, and namespace, the standard-library declarations the ambient file restates for a lib: [] program, and the shapes surface §14 and §28 admit;
  • (c) the TypeShade extensions enumerated in §9.3 of this document, one row per name with its reason.

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

근거

a name with a source has a meaning an author can look up; a name with no source has only the compiler’s word for what it does.

출처

PR #166’s body, section “A design rule this lane settled” (“No TypeShade-internal helper becomes an author-facing spelling”), and Declaration and Scope.

검증 방식

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

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

src/core/spec-conformance/surface-names.test.ts, which classifies every declared name against fixtures/wgsl-names.json, the running engine’s Math and console, and TYPESHADE_EXTENSIONS, and holds each method the library declares on an array to the running engine’s Array.prototype; and the front end, which resolves a name by what declares it and never by its spelling (proposal 0008): a name nothing declares is TS8022 for a value and TS8004 for a callee, in a body a call lowers and in one no call lowers alike, and TS8002 for a type wherever it is written, the base a class or an interface extends and an argument of a WGSL generic that is a type argument of a class included, once, in the compiler and in the editor alike (TypeScript’s TS2304, TS2583, TS2584, TS2591 and TS2580 merge into it), a name the file declares is the file’s whatever it spells, ahead of a type the library declares of the name, and a declaration of the file wins over a §9.3 constant of its name, and an enum, a namespace, a class or a type the file declares, read as a value, says what it is and the value it offers, once (TS8022, TypeScript’s report about its typeof merged into it), pinned by src/compiler/ts/host-names.test.ts and src/language-service/diagnostics.test.ts; the two spellings ECMAScript’s strict mode lets no declaration bind, eval and arguments, are refused once where a variable, a parameter or a function binds one, TS8068, as TypeScript’s TS1215 refuses them (TS1215, TS1210 and TS1100 merge into it, and so does what TypeScript says of a later write of the name), while a class, an enum, a namespace or a type of the name is the file’s, as TypeScript takes it, pinned by src/compiler/ts/host-names.test.ts; a new finds its class the same way, with what another block of a namespace exports, and a type annotation inside a namespace finds the class the new there builds, pinned by src/compiler/ts/new-expression.test.ts; the ambient library’s own types and values are names the compiler knows are declared, a type of its own says it is one where a type, a value or a callee is read (TypeScript’s TS2693 merges into it), and a shader type is none of them, pinned by src/language-service/ambient-parity.test.ts and src/compiler/ts/host-names.test.ts; and a member is looked up on its receiver, so a class field reverse or a method swizzle is the class’s, pinned by src/compiler/ts/class-methods.test.ts; a function the file declares under the name ref is the file’s, ahead of the library’s (Rule 8.25), pinned by src/compiler/ts/reference-parameters.test.ts.

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

설명하는 절

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

적용하는 오류 코드

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

TS8002 UNKNOWN_TYPE
A type name nothing declares, said once for the file wherever it is written (a parameter, a claim, a type argument, B<vec3<Foo>> included, an alias, an implements clause, the base a class or an interface extends, a body no call lowers), a type the library declares for TypeScript alone (Number) where the file declares none of its name, or a type this surface does not take in a position the mapper reads (Rule 2.1).
TS8004 UNKNOWN_FN
파일이 선언하지도 가져오지도 않은 함수를 부릅니다.
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.
TS8068 RESERVED_NAME
A declared name that a target reserves, checked on the name the emit actually carries: half as a struct field, which ANGLE answers with "Illegal use of reserved word" in generated text the author never wrote.

함께 보기

소스

커밋 c66579bf의 규칙 원문:

이 페이지 편집 문제 보고