diff --git a/lang/ast/expr/arith.c b/lang/ast/expr/arith.c index 3fede0f..526c161 100644 --- a/lang/ast/expr/arith.c +++ b/lang/ast/expr/arith.c @@ -662,6 +662,20 @@ struct token_parse_result arith_parse_right_brace( struct token_parse_result arith_parse_left_bracket( struct ivy_parser *ctx, struct ivy_token *tok) { + struct expr_parser_state *state + = parser_get_state(ctx, struct expr_parser_state); + + if (state->s_type == EXPR_TYPE_STMT) { + return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0); + } + + if (state->s_prev_component == EXPR_CMP_OPERAND) { + return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0); + } + + state->s_prev_token = IVY_SYM_LEFT_BRACKET; + state->s_type = EXPR_TYPE_ARITH; + parser_push_state(ctx, IVY_AST_LAMBDA, 0); return PARSE_RESULT(IVY_OK, 0); }