규칙 9.2
9장, 내장 함수와 TypeShade 확장 테스트
A builtin’s signature must be WGSL’s, checked at the call.
The two recorded exceptions are atan(y, x) (WGSL’s atan2) and the ECMAScript arity of the Math members.
A name of the f64 family, which has no WGSL signature, must take the signatures WGSL gives the type it stands in for (f64(x) as f32(x), vecNf64 as WGSL’s vector constructors), and a further signature of one is a new name under Rule 2.2.
규칙 본문과 그 아래 항목은 설계 문서에 적힌 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.
근거
an argument shape Tint refuses should be refused at the source line, with the splat or the cast to write; and a signature is a spelling, so an overload that no WGSL form has is a spelling from nowhere (§2.1).
출처
Numeric Built-in Functions; Value Constructor Built-in Functions for the scalar and vector constructor forms; surface §10 (#57), §39.
검증 방식
테스트로 확인합니다. 테스트나 게이트 스크립트, CI 워크플로가 이 규칙을 가리키고, 아래 파일 가운데 하나라도 규칙을 더는 가리키지 않으면 추적 검사가 실패합니다.
컴파일러가 이 규칙을 적용하는 곳을 규칙이 직접 적은 내용입니다.
TS8036 MATH_ARGUMENT and src/compiler/ts/lower/math-args.ts, whose rule for a name with SUPPORTED core.def rows is derived from those rows (0017); TS8019 for f64(a, b) (f64() expects 1 argument.) and surface-names.test.ts (the f64 family declares only the constructor forms WGSL gives the type it stands in for, the compiler refuses a second argument to f64).
커밋 c66579bf에서 이 규칙을 확인하는 파일입니다. 파일마다 규칙을 처음 가리키는 줄로 연결했습니다.
설명하는 절
커밋 c66579bf의 표면 문서에서 이 규칙을 설명하는 절입니다.
적용하는 오류 코드
규칙이 Enforced by 항목에서 가리키는 진단 코드와, 레지스트리 설명에서 이 규칙을 가리키는 진단 코드입니다.
-
TS8019ARITY_MISMATCH - Wrong number of arguments, elements, or fields at a call or constructor site.
-
TS8036MATH_ARGUMENT - A math builtin called with arguments its signature does not take: two shapes that had to agree (
dot(vec3, vec2),clamp(v, 0., 1.)with a vectorv), an element kind the builtin has no form for (sinon an integer vector,mixon one), a scalar where a vector is due (normalize(s),crosson avec2),mix's factor orrefract's eta of the wrong shape,ldexp's exponent not an i32 ofx's shape, a bit offset or count that is not au32, ortranspose/determinanton a non-matrix.
함께 보기
소스
커밋 c66579bf의 규칙 원문:
docs/language-design.md:937(설계 문서)reqs/rules/RULE-0902.md(추적 항목)