summaryrefslogtreecommitdiffhomepage
path: root/eval.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-08-25 19:41:49 +0200
committerJo-Philipp Wich <jo@mein.io>2020-08-25 20:38:15 +0200
commit93902cd86f8244b2036a0e5bd910099da13b6885 (patch)
tree89b081d5e4513a86895ac329d875cd8b76e251c8 /eval.c
parentd816fe346b390d122a42845318a6515d4d9badec (diff)
eval.c: properly propagate exceptions when resolving references
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/eval.c b/eval.c
index c55cbb7..a6e9dee 100644
--- a/eval.c
+++ b/eval.c
@@ -330,6 +330,7 @@ ut_getref_required(struct ut_state *state, struct ut_opcode *op, struct json_obj
tokennames[op->operand[0]->type], tokennames[op->type]);
}
+ *key = NULL;
return rv;
}
@@ -406,10 +407,7 @@ ut_execute_assign(struct ut_state *state, struct ut_opcode *op)
scope = ut_getref_required(state, label, &key);
- if (!scope)
- return NULL;
-
- return ut_setval(scope, key, ut_execute_op(state, value));
+ return key ? ut_setval(scope, key, ut_execute_op(state, value)) : scope;
}
static struct json_object *
@@ -740,8 +738,8 @@ ut_execute_inc_dec(struct ut_state *state, struct ut_opcode *op)
scope = ut_getref_required(state, label, &key);
- if (!scope)
- return NULL;
+ if (!key)
+ return scope;
val = ut_getval(scope, key);
@@ -1166,14 +1164,14 @@ ut_execute_op(struct ut_state *state, struct ut_opcode *op)
case T_DOT:
scope = ut_getref_required(state, op, &key);
- return ut_getval(scope, key);
+ return key ? ut_getval(scope, key) : scope;
case T_LBRACK:
/* postfix access */
if (op->val) {
scope = ut_getref_required(state, op, &key);
- return ut_getval(scope, key);
+ return key ? ut_getval(scope, key) : scope;
}
return ut_execute_list(state, op->operand[0]);