示例工程 05-variables-and-scope

05-variables-and-scope/04-undefined-global-silent/README.md

markdown · 0.6 KB

# 04 · undefined-global-silent
 
**演示**:`count` 拼成 `conut` 不会报错,只会把值写到另一个全局。
**运行时**:`lua54`、`luajit`。
**运行**:
 
```sh
.tools/bin/lua54 scripts/run-example.lua examples/05-variables-and-scope/04-undefined-global-silent
.tools/bin/lua54 scripts/test-example.lua examples/05-variables-and-scope/04-undefined-global-silent
```
 
**预期输出**(lua 5.4.9 / macOS arm64):
 
```text
count_is_nil=true
ghost=1
```
 
**看点**:语言层不报错,`luacheck` 的未声明全局检查才是门禁。
**注意**:示例故意写全局;该目录在 `.luacheckrc` 局部放行并注明原因。