diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-04-14 06:04:39 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-04-14 06:04:39 -0700 |
commit | a254e53a2c41763dec57ed213dfbd3fc4463acec (patch) | |
tree | 62519200e9d7bb1f1cb7c87f68a1d2da1dbbe97c | |
parent | 8c9e2dfeee4cb900e071bd50c59e1c1bdc468451 (diff) | |
download | egawk-a254e53a2c41763dec57ed213dfbd3fc4463acec.tar.gz egawk-a254e53a2c41763dec57ed213dfbd3fc4463acec.tar.bz2 egawk-a254e53a2c41763dec57ed213dfbd3fc4463acec.zip |
@let: bugfix: must clear dup_ent of re-used symbol.
* symbol.c (install): If parm is a recycled node coming from the
parser's let_free or let_gfree stack, it might have non-null
dup_ent. We must clear that, otherwise if we install that node
as a new entry, it will look like it has ghost duplicate list,
corrupting the variable allocation algorithm.
* test/let1.awk, test/let1.ok: Add tests, which broke.
-rw-r--r-- | symbol.c | 1 | ||||
-rw-r--r-- | test/let1.awk | 14 | ||||
-rw-r--r-- | test/let1.ok | 6 |
3 files changed, 21 insertions, 0 deletions
@@ -433,6 +433,7 @@ install(const char *name, NODE *parm, NODETYPE type) } if (type == Node_param_list || type == Node_alias) { + r->dup_ent = NULL; prev = in_array(table, n_name); if (prev == NULL) goto simple; diff --git a/test/let1.awk b/test/let1.awk index a67e3639..413b6e1e 100644 --- a/test/let1.awk +++ b/test/let1.awk @@ -143,3 +143,17 @@ BEGIN { exit 1 } } + +function f5() +{ + @let (x = 1) { print "f5", x } + @let (x = 1, y = 2) { print "f5", x, y } + @let (x = 1, y = 2, z = 3) { print "f5", x, y, z } +} + +BEGIN { + f5() + @let (x = 1) { print "b6", x } + @let (x = 1, y = 2) { print "b6", x, y } + @let (x = 1, y = 2, z = 3) { print "b6", x, y, z } +} diff --git a/test/let1.ok b/test/let1.ok index 153d9d96..f3336775 100644 --- a/test/let1.ok +++ b/test/let1.ok @@ -3,3 +3,9 @@ gawk: let1.awk:9: warning: function `f0' called with more arguments than declare f1 3 f2 3-8 b3 3-8 +f5 1 +f5 1 2 +f5 1 2 3 +b6 1 +b6 1 2 +b6 1 2 3 |