commit 53ebfbed6c3482be202bc7665d33d9b9c871bcce parent 7bfb0a5e3bdb49aa44fd3a6a5309be9157d04b3d Author: Ember Sawady <ecs@d2evs.net> Date: Mon, 6 Feb 2023 16:34:25 +0000 eval: don't crash on cast from error Signed-off-by: Ember Sawady <ecs@d2evs.net> Diffstat:
M | src/eval.c | | | 4 | ++++ |
M | tests/26-regression.ha | | | 1 | + |
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/src/eval.c b/src/eval.c @@ -564,6 +564,10 @@ eval_cast(struct context *ctx, struct expression *in, struct expression *out) return EVAL_OK; } + if (from->storage == STORAGE_ERROR) { + return EVAL_OK; + } + // XXX: We should also be able to handle expressions which use // symbols/identifiers diff --git a/tests/26-regression.ha b/tests/26-regression.ha @@ -108,4 +108,5 @@ export fn main() void = { def A = 0; fn a() void = A = 0;" ) as rt::exited != rt::EXIT_SUCCESS); + assert(rt::compile("def A = x && true;") as rt::exited != rt::EXIT_SUCCESS); };