TS8023
프런트엔드 코드 DUPLICATE_SYMBOL
The same function, binding, module constant or struct name declared twice in one scope.
레지스트리 설명과 컴파일러 메시지는 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.
발생 조건
The same function, binding, module constant or struct name declared twice in one scope. A struct counts whichever of the three spellings each declaration used: a class, an interface and a type alias of one name are one struct, not declarations that merge.
예제
"use typeshade"
function shade(x: f32): f32 { return x * 0.5}
function shade(x: f32): f32 { return x * 0.25}
@fragmentexport function main(@location(0) uv: vec2): vec4 { return vec4(uv, shade(uv.x), 1.)}빌드할 때 고정된 컴파일러로 이 프로그램을 컴파일하면 다음 진단이 나옵니다.
TS8023 error, 7행: Duplicate function "shade".
고치는 법
같은 프로그램을 고친 모습입니다. 진단 없이 컴파일됩니다.
"use typeshade"
function shade(x: f32): f32 { return x * 0.5}
function shadeQuarter(x: f32): f32 { return x * 0.25}
@fragmentexport function main(@location(0) uv: vec2): vec4 { return vec4(uv, shade(uv.x) + shadeQuarter(uv.y), 1.)}이 코드가 적용하는 규칙
- 규칙 4.2 테스트
- A type alias is another name for its target.
함께 보기
소스
커밋 c66579bf에서 컴파일러가 이 코드를 내는 곳입니다. 파일마다 한 줄씩 적었습니다.
-
src/compiler/ts/bindings.ts:139 -
src/compiler/ts/link.ts:1033 -
src/compiler/ts/lower/control.ts:636 -
src/compiler/ts/lower/function.ts:260(4곳) -
src/compiler/ts/lower/statement.ts:471(3곳) -
src/compiler/ts/module-const.ts:278(2곳) -
src/compiler/ts/module-vars.ts:218(2곳) -
src/compiler/ts/source-file.ts:763 -
src/compiler/ts/structs.ts:267(2곳)