TS8004
프런트엔드 코드 UNKNOWN_FN
파일이 선언하지도 가져오지도 않은 함수를 부르거나, ECMAScript 표기가 있어서 언어에서 뺀 내장 함수를 부릅니다. arrayLength(xs)가 그 예이며, 메시지가 대신 쓸 xs.length를 알려 줍니다(규칙 9.9).
레지스트리에는 이 상수에 대한 문서 주석이 없습니다. 그래서 위 설명은 컴파일러가 이 코드와 함께 내는 메시지를 보고 이 사이트가 쓴 것입니다.
레지스트리 설명과 컴파일러 메시지는 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.
예제
"use typeshade"
@fragmentexport function main(uv: location<0, vec2>): vec4 { return vec4(uv, brightness(uv), 1.)}빌드할 때 고정된 컴파일러로 이 프로그램을 컴파일하면 다음 진단이 나옵니다.
TS8004 error, 5행: Unknown function "brightness". Declare it in this file, or import it from another shader module.
고치는 법
같은 프로그램을 고친 모습입니다. 진단 없이 컴파일됩니다.
"use typeshade"import { brightness } from "./brightness.shade.ts"
@fragmentexport function main(uv: location<0, vec2>): vec4 { return vec4(uv, brightness(uv), 1.)}같은 프로그램의 다른 파일에서 가져오며, compile()은 그 파일을 readDocument 옵션으로 읽습니다.
"use typeshade"
export function brightness(uv: vec2): f32 { return (uv.x + uv.y) * 0.5}이 코드가 적용하는 규칙
- 규칙 2.1 테스트
- Every author-facing name must come from exactly one of three sources:
- 규칙 2.2 테스트
- A compiler-internal name (§2.1) must not be authorable.
- 규칙 7.7 테스트
discardmust be written as a bare statement, the identifier alone (discard), and may stand in a fragment entry and in a helper no vertex or compute entry can reach.- 규칙 9.9 테스트
- A WGSL built-in function, an overload of one, or a §9.3 name must not be authorable when an ECMAScript spelling the compiler supports carries every case it accepts with the same meaning (Rule 1.4).
함께 보기
소스
커밋 af54ddad5에서 컴파일러가 이 코드를 내는 곳입니다. 파일마다 한 줄씩 적었습니다.
-
src/compiler/ts/lower/expression-call.ts:435(3곳) -
src/compiler/ts/semantic.ts:616 -
src/compiler/ts/source-file.ts:476 -
src/core/coverage/glsl/common-functions.ts:101 -
src/core/coverage/glsl/float-bits-and-packing.ts:10(2곳) -
src/core/coverage/glsl/geometric-and-matrix.ts:90(3곳) -
src/core/coverage/glsl/texture-lookups.ts:32(9곳) -
src/core/coverage/wgsl/derivative-and-float-functions.ts:209 -
src/core/coverage/wgsl/functions-i32-to-normalize.ts:209 -
src/core/coverage/wgsl/texture-query-and-load-functions.ts:116 -
src/core/coverage/wgsl/texture-sample-functions.ts:31