TS8036
프런트엔드 코드 MATH_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 vector v), an element kind the builtin has no form for (sin on an integer vector, mix on one), a scalar where a vector is due (normalize(s), cross on a vec2), mix's factor or refract's eta of the wrong shape, ldexp's exponent not an i32 of x's shape, a bit offset or count that is not a u32, or transpose/determinant on a non-matrix.
레지스트리 설명과 컴파일러 메시지는 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.
발생 조건
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 vector v), an element kind the builtin has no form for (sin on an integer vector, mix on one), a scalar where a vector is due (normalize(s), cross on a vec2), mix's factor or refract's eta of the wrong shape, ldexp's exponent not an i32 of x's shape, a bit offset or count that is not a u32, or transpose/determinant on a non-matrix. Named on the offending argument with the fix where one is short: splat the scalar, cast one side, give the vectors one size.
예제
"use typeshade"
@fragmentexport function main(@location(0) uv: vec2): vec4 { const n = vec3(0., 0., 1.) return vec4(uv, dot(n, uv), 1.)}빌드할 때 고정된 컴파일러로 이 프로그램을 컴파일하면 다음 진단이 나옵니다.
TS8036 error, 6행: dot takes arguments of one type; the first is vec3, this one vec2. Give the vectors one size.
고치는 법
같은 프로그램을 고친 모습입니다. 진단 없이 컴파일됩니다.
"use typeshade"
@fragmentexport function main(@location(0) uv: vec2): vec4 { const n = vec3(0., 0., 1.) return vec4(uv, dot(n, vec3(uv, 1.)), 1.)}이 코드가 적용하는 규칙
함께 보기
소스
커밋 c66579bf에서 컴파일러가 이 코드를 내는 곳입니다. 파일마다 한 줄씩 적었습니다.