---
title: "SD0112: a local name is declared twice in one function"
description: "SD0112, an error code of the TypeShade compiler. a local name is declared twice in one function"
url: https://typeshade.dev/reference/errors/sd0112/
language: en
---

# `SD0112`

Core code

a local name is declared twice in one function

No `"use typeshade"` program on this site raises this code, so the page has no example. The [`fn()`](https://typeshade.dev/api/fn/) builder builds the IR directly and reaches the check at the lines under Source.

The registry text and every compiler message on these pages are the compiler's own English.

## When it fires

The optimizer's per-function maps are keyed on a binding's name alone, so a duplicate name merges two bindings. Reported per violation by the no-shadowed-local rule (core, so at every emit on both writers) and thrown by `fixpoint`, which additionally covers a direct optimizeAt() caller and the post-lowering module the rule never sees.

## How to fix it

The registry's hint: rename one of the two bindings, or omit the name (b.let(value) / b.var(type)) to take a function-unique auto name — the optimizer keys its per-function maps on the name alone, so two bindings sharing one name collapse into one

## See also

- [Diagnostics](https://typeshade.dev/guide/internals/diagnostics/)
- [`TypeShadeError`](https://typeshade.dev/api/typeshadeerror/)
- [Error codes](https://typeshade.dev/reference/errors/)

## Source

Where the compiler raises this code at commit af54ddad5, one line per file:

- [`src/core/passes/lint/rules/no-shadowed-local.ts:71`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/passes/lint/rules/no-shadowed-local.ts#L71)
- [`src/core/passes/opt/optimize.ts:264`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/passes/opt/optimize.ts#L264)
