mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 08:54:53 +00:00
fixes #5395 Previously values of `const` statements used the same scope as the `const` statement itself, meaning variables could be declared inside them and referred to in other statements in the same block. Now each `const` value opens its own scope, so any variable declared in the value of a constant can only be accessed for that constant. We could change this to open a new scope for the `const` *section* rather than each constant, so the variables can be used in other constants, but I'm not sure if this is sound.
6 lines
94 B
Nim
6 lines
94 B
Nim
# issue #5395
|
|
|
|
const a = (var b = 3; b)
|
|
echo b #[tt.Error
|
|
^ undeclared identifier: 'b']#
|