From 41031bff7d6321defff9829365381ce4569fa4d7 Mon Sep 17 00:00:00 2001 From: vssukharev Date: Wed, 13 Nov 2024 23:00:38 +0200 Subject: [PATCH] #1618: Fixed a bug when contract is not applied when it's written after '*' symbol --- src/compiler/enums.h | 4 ++-- src/compiler/lexer.c | 1 - src/compiler/parse_global.c | 4 ++++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/compiler/enums.h b/src/compiler/enums.h index 48b26482b..aa8ad1c4b 100644 --- a/src/compiler/enums.h +++ b/src/compiler/enums.h @@ -1240,8 +1240,8 @@ typedef enum TOKEN_CT_VAEXPR, // $vaexpr, TOKEN_CT_VASPLAT, // $vasplat, TOKEN_LAST_KEYWORD = TOKEN_CT_VASPLAT, - TOKEN_DOCS_START, // /** - TOKEN_DOCS_END, // */ (may start with an arbitrary number of `*` + TOKEN_DOCS_START, // <* + TOKEN_DOCS_END, // *> (may start with an arbitrary number of `*` TOKEN_DOCS_EOL, TOKEN_EOF, // \n - SHOULD ALWAYS BE THE LAST TOKEN. diff --git a/src/compiler/lexer.c b/src/compiler/lexer.c index 1cabdd1ac..e60480f92 100644 --- a/src/compiler/lexer.c +++ b/src/compiler/lexer.c @@ -1197,7 +1197,6 @@ static bool parse_doc_start(Lexer *lexer) case '*': // We might have <* Hello *> if (peek_next(lexer) == '>') goto EXIT; - may_have_contract = false; next(lexer); continue; case '@': diff --git a/src/compiler/parse_global.c b/src/compiler/parse_global.c index 1ce3fa4fa..9f61d179f 100644 --- a/src/compiler/parse_global.c +++ b/src/compiler/parse_global.c @@ -4,6 +4,7 @@ #include "compiler_internal.h" #include "parser_internal.h" +#include typedef enum FunctionParse_ { @@ -2660,6 +2661,9 @@ static bool parse_contracts(ParseContext *c, AstId *contracts_ref) // Skip empty lines. if (try_consume(c, TOKEN_DOCS_EOL)) continue; + // If we have a '*', skip it and continue reading + if (try_consume(c, TOKEN_STAR)) continue; + if (!tok_is(c, TOKEN_AT_IDENT)) { PRINT_ERROR_HERE("Expected a directive starting with '@' here, like '@param' or `@require`");