TS8003
프런트엔드 코드 TYPE_MISMATCH
연산자나 조건, 선언, 반환, 인자처럼 두 값이 만나는 자리에서 타입이 서로 맞지 않거나, 컴파일러가 접는 상수를 WGSL이 거부합니다. 31을 넘는 시프트 양, 0인 제수, 서로 엇갈린 clamp 경계, 범위를 넘는 f32 값이 그렇습니다.
레지스트리에는 이 상수에 대한 문서 주석이 없습니다. 그래서 위 설명은 컴파일러가 이 코드와 함께 내는 메시지를 보고 이 사이트가 쓴 것입니다.
레지스트리 설명과 컴파일러 메시지는 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.
예제
"use typeshade"
@fragmentexport function main(@location(0) uv: vec2): vec4 { return vec4(uv + vec3(0.5, 0.5, 0.5), 1.)}빌드할 때 고정된 컴파일러로 이 프로그램을 컴파일하면 다음 진단이 나옵니다.
TS8003 error, 5행: Type mismatch: cannot + vec2 and vec3. Vectors must have the same size.
고치는 법
같은 프로그램을 고친 모습입니다. 진단 없이 컴파일됩니다.
"use typeshade"
@fragmentexport function main(@location(0) uv: vec2): vec4 { return vec4(vec3(uv, 0.) + vec3(0.5, 0.5, 0.5), 1.)}이 코드가 적용하는 규칙
- 규칙 2.3 테스트
- A value sometimes has to cross between a representation the compiler chose and one the target has: an
f64and the twof32halves that carry it across an interface off32. - 규칙 4.8 테스트
- Every
matCxRwithCandRin 2, 3, 4 must be a type, and a square one must also answer tomatN. - 규칙 5.3 테스트
- There is no implicit conversion between concrete types; an
i32beside au32, or an integer beside a float, must be refused with the cast to write. - 규칙 5.4 테스트
- A literal must fit the type it takes;
-1in au32position and2147483648in ani32position are refused as written. - 규칙 6.3 테스트
- A top-level
constis a module constant: a scalar must fold to one value carried at double precision for the oracle and at the target’s precision for emit, and a vector, array, or struct must carry a constant-foldable expression every backend evaluates. - 규칙 7.1 테스트
- An operator, a swizzle, an index, and a call must mean what WGSL’s typing table gives them.
- 규칙 7.4 테스트
- A shift amount the compiler can fold must be in 0 to 31; a divisor the compiler can prove to be zero must be refused where the division is lowered.
- 규칙 7.5 테스트
- A
forloop must be counted: ani32oru32induction variable, a constant step, and an exit that compares the induction variable to a bound; the start and the bound may be runtime values, the loop body must not write the bound, and the step must move the variable toward the bound. - 규칙 8.18 테스트
- A function whose parameter has a function type, written out (
f: (x: f32) => f32) or through a type alias of one, takes a function: a function declared at the top of the file or of a namespace, a method, a static method, a constructor, a field that holds a function (Rule 8.16) and a local function (Rule 8.17). - 규칙 8.19 테스트
- A function that writes no return type returns what its body does, as TypeScript infers it: a function of the file or of a namespace, a local function (Rule 8.17), each instance of a generic function (Rule 8.9) and of a function that takes a function (Rule 8.18), a method, a getter and a field that holds a function (Rule 8.16) take the type of their first
returnwith a value, thereturns after it are typed against that type as against a written one, and one with no suchreturnreturns nothing. - 규칙 12.6 테스트
- A requirement the front end can check must be checked at the front end, in the author’s words, and not left to Tint or a driver.
함께 보기
-
SD0001 - matrix × vector size mismatch
-
SD0002 - binary op on mismatched vectors
-
SD0003 - arithmetic op on a bool operand
-
SD0004 - binary op on incompatible types
-
SD0009 - .select() on a non-bool condition
-
SD0010 - select branches have differing types
-
SD0017 - literal cannot be spelled by the target
-
SD0041 - unsupported operation on f64 operands
소스
커밋 c66579bf에서 컴파일러가 이 코드를 내는 곳입니다. 파일마다 한 줄씩 적었습니다.
-
src/compiler/ts/builtin-check.ts:377(4곳) -
src/compiler/ts/lit-coerce.ts:254 -
src/compiler/ts/lower/array-methods.ts:157(6곳) -
src/compiler/ts/lower/atomics.ts:94(5곳) -
src/compiler/ts/lower/barriers.ts:149 -
src/compiler/ts/lower/class-methods.ts:1652 -
src/compiler/ts/lower/control.ts:145(6곳) -
src/compiler/ts/lower/expression-array.ts:112(9곳) -
src/compiler/ts/lower/expression-call.ts:563(42곳) -
src/compiler/ts/lower/expression-misc.ts:69(4곳) -
src/compiler/ts/lower/expression-prop.ts:123(3곳) -
src/compiler/ts/lower/expression.ts:121(23곳) -
src/compiler/ts/lower/function-args.ts:139(4곳) -
src/compiler/ts/lower/function.ts:2904(3곳) -
src/compiler/ts/lower/index-select.ts:26(5곳) -
src/compiler/ts/lower/operator-kinds.ts:222(3곳) -
src/compiler/ts/lower/statement.ts:480(14곳) -
src/compiler/ts/module-const.ts:218(13곳) -
src/language-service/diagnostics.ts:2443