TS8023
Front-end code DUPLICATE_SYMBOL
The same function, binding, module constant or struct name declared twice in one scope. A struct counts whichever spelling each declaration uses: a class, an interface and a type alias of one name are one struct, so a second declaration is a duplicate.
The registry has no documentation comment for this constant, so the line above is written by this site from the messages the compiler raises it with.
The registry text and every compiler message on these pages are the compiler's own English.
Example
"use typeshade"
function shade(x: f32): f32 { return x * 0.5}
function shade(x: f32): f32 { return x * 0.25}
@fragmentexport function main(uv: location<0, 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(uv: location<0, 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 af54ddad5, one line per file:
-
src/compiler/ts/bindings.ts:115 -
src/compiler/ts/link.ts:814 -
src/compiler/ts/lower/control/for-of.ts:128 -
src/compiler/ts/lower/function.ts:357(4 sites) -
src/compiler/ts/lower/second-name.ts:153 -
src/compiler/ts/lower/statement/declaration-kind.ts:94(2 sites) -
src/compiler/ts/lower/statement/define-local.ts:47 -
src/compiler/ts/module-const.ts:204(2 sites) -
src/compiler/ts/module-vars.ts:215(2 sites) -
src/compiler/ts/source-file.ts:825 -
src/compiler/ts/structs/add-struct.ts:73 -
src/compiler/ts/structs/candidates.ts:67