aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/parse.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/parse.c b/src/parse.c
index 511cb18..3fa1498 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -1097,8 +1097,10 @@ parse_return(struct lexer *lexer, struct ast_return *out)
return false;
}
- if (!parse_expr(lexer, &out->value)) {
- error(lex_loc(lexer), "syntax error: expected expression");
+ out->value = must_malloc(sizeof(struct ast_expr));
+ if (!parse_expr(lexer, out->value)) {
+ free(out->value);
+ out->value = NULL;
}
return true;