TS8023
Front-end code DUPLICATE_SYMBOL
The same function, binding, module constant or struct name declared twice in one scope.
The registry text and every compiler message on these pages are the compiler's own English.
When it fires
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.
Example
"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.)}Compiled at build time against the pinned compiler, this program gets:
TS8023 error, line 7: Duplicate function "shade".
How to fix it
The same program, corrected. It compiles with no diagnostic.
"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.)}The rule this enforces
- Rule 4.2 Test
- A type alias is another name for its target.
See also
Source
Where the compiler raises this code at commit 26de7be8, one line per file:
-
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:236(4 sites) -
src/compiler/ts/lower/statement.ts:471(3 sites) -
src/compiler/ts/module-const.ts:278(2 sites) -
src/compiler/ts/module-vars.ts:218(2 sites) -
src/compiler/ts/source-file.ts:763 -
src/compiler/ts/structs.ts:267(2 sites)