diff options
-rw-r--r-- | interpret.h | 6 | ||||
-rw-r--r-- | test/let1.awk | 7 |
2 files changed, 12 insertions, 1 deletions
diff --git a/interpret.h b/interpret.h index ef087951..0dc261d6 100644 --- a/interpret.h +++ b/interpret.h @@ -743,6 +743,7 @@ mod: break; case Op_clear_var: + { /* * Clear variable to the undefined value * that is equal to 0 and "" represented by @@ -751,7 +752,8 @@ mod: * locals, which may re-use previously * initialized frame locations. */ - lhs = get_lhs(pc->memory, false); + NODE *var = pc->memory; + lhs = get_lhs(var, false); /* * If it's already clear, nothing to do @@ -760,6 +762,8 @@ mod: unref(*lhs); *lhs = dupnode(Nnull_string); } + var->type = Node_var_new; + } break; case Op_store_field: diff --git a/test/let1.awk b/test/let1.awk index 94a1a681..431fb8b8 100644 --- a/test/let1.awk +++ b/test/let1.awk @@ -38,6 +38,13 @@ BEGIN { print "b3", l3 "-" x } +# test re-use of scalar var as array + +BEGIN { + @let (i = 3) { } + @let (a) { a[0] = 42 } +} + # test clearing uninitialized variables function f4() |