Fixed crash on unknown var name.
This commit is contained in:
parent
eaf65697de
commit
18c61d86dc
14
src/exec.c
14
src/exec.c
@ -114,7 +114,19 @@ AST* exec_vref(AST* ast) {
|
||||
log_dbg("attempting to reference var");
|
||||
ASTVrefData* vref = (ASTVrefData*)ast->data;
|
||||
|
||||
return exec_exp(exec_find(vref->to));
|
||||
AST* found = exec_find(vref->to);
|
||||
|
||||
if (found == NULL) {
|
||||
// TODO: Better memory management here.
|
||||
static char msg[256];
|
||||
snprintf(
|
||||
msg, sizeof(msg), "Could not find value in scope for `%s`.",
|
||||
vref->to
|
||||
);
|
||||
return ast_init(AST_TYPE_EXC, msg);
|
||||
}
|
||||
|
||||
return exec_exp(found);
|
||||
}
|
||||
|
||||
void exec_print(double n) { printf("= %lf\n", n); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user