# 01 · local-scope-shadowing **演示**:`do ... end` 内的 `local value` 遮蔽外层;内层修改不改变外层。 **运行时**:`lua54`、`luajit`。 **运行**: ```sh .tools/bin/lua54 scripts/run-example.lua examples/05-variables-and-scope/01-local-scope-shadowing .tools/bin/lua54 scripts/test-example.lua examples/05-variables-and-scope/01-local-scope-shadowing ``` **预期输出**(lua 5.4.9 / macOS arm64): ```text inner=2 outer=1 after=1 ``` **看点**:作用域是词法的,由源码块决定,不是运行时栈。 **注意**:同名变量遮蔽是常见 bug 来源,`luacheck` 的 `redefined` 会提示。 **luacheck 局部放行**:内层同名变量是本例要演示的行为。