commit 22217da91dd27690b9ac75357bcdb68e86d1177c
parent 1df1186ec66e6ac19c494b99c9253a2fe4fd8c2d
Author: Ember Sawady <ecs@d2evs.net>
Date: Wed, 1 Feb 2023 21:47:09 +0000
Don't crash on compile time &0
Or more broadly, non-access expressions
Signed-off-by: Ember Sawady <ecs@d2evs.net>
Diffstat:
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/eval.c b/src/eval.c
@@ -934,7 +934,9 @@ eval_unarithm(struct context *ctx, struct expression *in, struct expression *out
out->result = &builtin_type_error;
return EVAL_OK;
}
- assert(in->unarithm.operand->type == EXPR_ACCESS);
+ if (in->unarithm.operand->type != EXPR_ACCESS) {
+ return EVAL_INVALID;
+ };
// TODO other access types
assert(in->unarithm.operand->access.type == ACCESS_IDENTIFIER);
if (in->unarithm.operand->access.object->otype != O_DECL) {
diff --git a/tests/26-regression.ha b/tests/26-regression.ha
@@ -90,4 +90,5 @@ export fn main() void = {
};
def A: a = a { b = 0 };"
) as rt::exited != rt::EXIT_SUCCESS);
+ assert(rt::compile("let a = &0;") as rt::exited != rt::EXIT_SUCCESS);
};