commit 20059b1233d0b4be1f9d45f6800e0a51f9af1fd0 parent f5082c2fc369c8f78d11ddbe25829866b21855ed Author: Demonstrandum <moi@knutsen.co> Date: Sat, 27 Jun 2020 09:51:40 +0100 Catch error on no right side of prefix operators Diffstat:
M | src/parse.c | | | 6 | ++++++ |
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/parse.c b/src/parse.c @@ -308,6 +308,12 @@ ParseNode *parse_prefix(const Token *token, char **rest) unary->callee = callee; unary->operand = parse_expr(rest, precedence); + if (unary->operand == NULL) { + ERROR_TYPE = PARSE_ERROR; + sprintf(ERROR_MSG, "Missing right-hand-side of prefix" + " operator `%s'.", token->value); + return NULL; + } unary->is_postfix = false; node->type = UNARY_NODE;