Allow variable to overwrite constant when shadowing.

This commit is contained in:
Stephen Chung
2022-02-18 19:14:42 +08:00
parent 78b5c9fd4e
commit 67a6638818
2 changed files with 15 additions and 5 deletions

View File

@@ -2663,13 +2663,10 @@ fn parse_let(
AST_OPTION_NONE
};
let existing = state.stack.get_index(&name).and_then(|(n, a)| {
let existing = state.stack.get_index(&name).and_then(|(n, ..)| {
if n < state.block_stack_len {
// Defined in parent block
None
} else if a == AccessMode::ReadOnly && access != AccessMode::ReadOnly {
// Overwrite constant
None
} else {
Some(n)
}