diff options
author | Jo-Philipp Wich <jo@mein.io> | 2020-09-23 14:33:47 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2020-09-23 14:33:47 +0200 |
commit | 2bb74a2f510f359713b4f4710ad88d81440a51b3 (patch) | |
tree | f6f5107a1290980166b8b5c6dd38759427d3a468 | |
parent | b4c605e8ab49e35dfbb7caa179eaa273c696ac9f (diff) |
eval: propagate exceptions when resolving references
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r-- | eval.c | 20 |
1 files changed, 13 insertions, 7 deletions
@@ -367,17 +367,23 @@ ut_getref_required(struct ut_state *state, uint32_t off, struct json_object **ke if (!json_object_is_type(scope, json_type_array) && !json_object_is_type(scope, json_type_object)) { - lhs = off1 ? ut_ref_to_str(state, off1) : NULL; + if (!ut_is_type(scope, T_EXCEPTION)) { + lhs = off1 ? ut_ref_to_str(state, off1) : NULL; - if (lhs) { - p = alloca_sprintf("Type error: the result of `%s` is %s", lhs, - scope ? "not an array or object" : "null"); - free(lhs); + if (lhs) { + p = alloca_sprintf("Type error: the result of `%s` is %s", lhs, + scope ? "not an array or object" : "null"); + free(lhs); + } + + json_object_put(scope); + rv = ut_exception(state, off1, p ? p : "Type error: left-hand side is not an array or object"); + } + else { + rv = scope; } - json_object_put(scope); json_object_put(skey); - rv = ut_exception(state, off1, p ? p : "Type error: left-hand side is not an array or object"); *key = NULL; return rv; |