Variable/identifier shadowing

Functional Logic & Control Flow

Last updated: November 10, 2025

Overview

Bug Type:
Variable/identifier shadowing
Category:
Functional Logic & Control Flow

Definition

A local identifier hides an outer one, leading to reads/writes on the wrong variable.

How to fix Variable/identifier shadowing?

Enable linter rules (no-shadow); rename conflicting vars; reduce scope; prefer small functions to avoid ambiguous contexts

Symptoms

Observable signs that may indicate Variable/identifier shadowing:

  • Assignments have no effect outside block scope.
  • Unexpected value read due to inner variable masking outer one.
  • Linters warn about shadowed variables.

Example Errors:

  • ESLint: 'result' is already declared in the upper scope.
  • Shadowed variable 'config'
  • TypeScript: Block-scoped variable used before declaration

© 2025 peqy.ai · Bug Taxonomy