diff options
author | Jo-Philipp Wich <jo@mein.io> | 2020-09-16 23:34:30 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2020-09-16 23:34:30 +0200 |
commit | 0e67bdaa847c6d67497016db52e06af357f2e85c (patch) | |
tree | 5af316649c506c17c645c782c0519e27392b9d03 /eval.c | |
parent | 54bb15b2be3656e91386b80074f45591b20fed3f (diff) |
treewide: implement strict assignment mode
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -303,8 +303,14 @@ ut_getref(struct ut_state *state, uint32_t off, struct json_object **key) next = ut_getscope(state, ++i); - if (!next) + if (!next) { + if (state->strict_declarations) + ut_throw(state, off, + "Reference error: access to undeclared variable %s", + json_object_get_string(op->val)); + break; + } scope = next; } @@ -1356,6 +1362,11 @@ ut_execute_op(struct ut_state *state, uint32_t off) ut_putval(state->ctx); state->ctx = NULL; + if (state->strict_declarations && scope == NULL) { + ut_throw(state, off, "Reference error: %s is not defined", + json_object_get_string(op->val)); + } + val = ut_getval(scope, key); ut_putval(scope); |