From 3afec0bcbe630d707e97fb12474b44eed42a5b87 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 10 Jul 2021 11:42:21 +0100 Subject: [PATCH] Fix #1054 --- src/parser.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/parser.cpp b/src/parser.cpp index 9bb4a9c3c..7e7b317c4 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -1879,13 +1879,13 @@ Ast *parse_force_inlining_operand(AstFile *f, Token token) { if (e->kind == Ast_ProcLit) { if (expr->ProcLit.inlining != ProcInlining_none && expr->ProcLit.inlining != pi) { - syntax_error(expr, "You cannot apply both '#force_inline' and '#force_no_inline' to a procedure literal"); + syntax_error(expr, "Cannot apply both '#force_inline' and '#force_no_inline' to a procedure literal"); } expr->ProcLit.inlining = pi; } else if (e->kind == Ast_CallExpr) { if (expr->CallExpr.inlining != ProcInlining_none && expr->CallExpr.inlining != pi) { - syntax_error(expr, "You cannot apply both '#force_inline' and '#force_no_inline' to a procedure call"); + syntax_error(expr, "Cannot apply both '#force_inline' and '#force_no_inline' to a procedure call"); } expr->CallExpr.inlining = pi; } @@ -1925,6 +1925,12 @@ Ast *parse_operand(AstFile *f, bool lhs) { Token open, close; // NOTE(bill): Skip the Paren Expression open = expect_token(f, Token_OpenParen); + if (f->prev_token.kind == Token_CloseParen) { + close = expect_token(f, Token_CloseParen); + syntax_error(open, "Invalid parentheses expression with no inside expression"); + return ast_bad_expr(f, open, close); + } + allow_newline = f->allow_newline; if (f->expr_level < 0) { f->allow_newline = false; @@ -3555,7 +3561,9 @@ Ast *parse_field_list(AstFile *f, isize *name_count_, u32 allowed_flags, TokenKi if (f->curr_token.kind != Token_Eq) { type = parse_var_type(f, allow_ellipsis, allow_typeid_token); Ast *tt = unparen_expr(type); - if (is_signature && !any_polymorphic_names && tt->kind == Ast_TypeidType && tt->TypeidType.specialization != nullptr) { + if (tt == nullptr) { + syntax_error(f->prev_token, "Invalid type expression in field list"); + } else if (is_signature && !any_polymorphic_names && tt->kind == Ast_TypeidType && tt->TypeidType.specialization != nullptr) { syntax_error(type, "Specialization of typeid is not allowed without polymorphic names"); } }