From 4e78e32ced8572f14c74fd92261a7b97c6097ed0 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Sun, 12 Jan 2025 14:19:19 +0100 Subject: [PATCH] Fix regression with contract docs and generics #1821 --- src/compiler/sema_decls.c | 5 +++-- test/test_suite/generic/generic_with_comment.c3t | 13 +++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 test/test_suite/generic/generic_with_comment.c3t diff --git a/src/compiler/sema_decls.c b/src/compiler/sema_decls.c index c51d3b9b9..edeadd8ef 100755 --- a/src/compiler/sema_decls.c +++ b/src/compiler/sema_decls.c @@ -4444,9 +4444,10 @@ static bool sema_analyse_generic_module_contracts(SemaContext *c, Module *module { Ast *ast = astptr(contract); contract = ast->next; - ASSERT0(ast->ast_kind == AST_CONTRACT); + ASSERT(ast, ast->ast_kind == AST_CONTRACT); SemaContext temp_context; - ASSERT0(ast->contract_stmt.kind == CONTRACT_REQUIRE); + if (ast->contract_stmt.kind == CONTRACT_COMMENT) continue; + ASSERT(ast, ast->contract_stmt.kind == CONTRACT_REQUIRE); SemaContext *new_context = context_transform_for_eval(c, &temp_context, module->units[0]); FOREACH(Expr *, expr, ast->contract_stmt.contract.decl_exprs->expression_list) { diff --git a/test/test_suite/generic/generic_with_comment.c3t b/test/test_suite/generic/generic_with_comment.c3t new file mode 100644 index 000000000..7db9f04f3 --- /dev/null +++ b/test/test_suite/generic/generic_with_comment.c3t @@ -0,0 +1,13 @@ +module test; +import generic; + +// Issue #1821 +fn void main() { + Generic() asdf; +} + +<* + Hello +*> +module generic(); +struct Generic { int a; } \ No newline at end of file