diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2021-09-10 10:43:21 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2021-09-10 10:43:21 +0300 |
commit | c89ce5850cf9dc9173364de62bb183b207826e96 (patch) | |
tree | 3a43121188751d50b1b2f0cbdae63fb64f03057d /interpret.h | |
parent | 769de8893a550b3439aabe7c754fbf9cafa45df8 (diff) | |
download | egawk-c89ce5850cf9dc9173364de62bb183b207826e96.tar.gz egawk-c89ce5850cf9dc9173364de62bb183b207826e96.tar.bz2 egawk-c89ce5850cf9dc9173364de62bb183b207826e96.zip |
Bug fix for FUNCTAB and SYMTAB. Update tests.
Diffstat (limited to 'interpret.h')
-rw-r--r-- | interpret.h | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/interpret.h b/interpret.h index 2ed4f01a..4495d8cc 100644 --- a/interpret.h +++ b/interpret.h @@ -67,6 +67,7 @@ r_interpret(INSTRUCTION *code) Regexp *rp; NODE *set_array = NULL; /* array with a post-assignment routine */ NODE *set_idx = NULL; /* the index of the array element */ + bool subscript_in_array; /* array subscript */ @@ -265,14 +266,27 @@ uninitialized_scalar: t2 = mk_sub(pc->sub_count); t1 = POP_ARRAY(false); - if (do_lint && in_array(t1, t2) == NULL) { + subscript_in_array = (in_array(t1, t2) != NULL); + + if (! subscript_in_array) { t2 = force_string(t2); - lintwarn(_("reference to uninitialized element `%s[\"%.*s\"]'"), - array_vname(t1), (int) t2->stlen, t2->stptr); - if (t2->stlen == 0) - lintwarn(_("subscript of array `%s' is null string"), array_vname(t1)); + + if (t1 == func_table) { + fatal(_("reference to uninitialized element `%s[\"%.*s\"] is not allowed'"), + "FUNCTAB", (int) t2->stlen, t2->stptr); + } else if (t1 == symbol_table) { + fatal(_("reference to uninitialized element `%s[\"%.*s\"] is not allowed'"), + "SYMTAB", (int) t2->stlen, t2->stptr); + } else if (do_lint) { + lintwarn(_("reference to uninitialized element `%s[\"%.*s\"]'"), + array_vname(t1), (int) t2->stlen, t2->stptr); + if (t2->stlen == 0) + lintwarn(_("subscript of array `%s' is null string"), array_vname(t1)); + } } + // continue the regular processing + /* for FUNCTAB, get the name as the element value */ if (t1 == func_table) { static bool warned = false; |