diff --git a/releasenotes.md b/releasenotes.md index 5adc6b83f..37be342be 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -15,6 +15,7 @@ - Fix No index OOB check for `[:^n]` #2123. - Fix regression in Time diff due to operator overloading #2124. - attrdef with any invalid name causes compiler assert #2128. +- Correctly error on `@attrdef Foo = ;`. ### Stdlib changes - Added `String.quick_ztr` and `String.is_zstr` diff --git a/src/compiler/parse_global.c b/src/compiler/parse_global.c index 63f22800e..04266984b 100644 --- a/src/compiler/parse_global.c +++ b/src/compiler/parse_global.c @@ -2229,6 +2229,12 @@ static inline Decl *parse_attrdef(ParseContext *c) if (try_consume(c, TOKEN_EOS)) return decl; CONSUME_OR_RET(TOKEN_EQ, poisoned_decl); + if (tok_is(c, TOKEN_EOS)) + { + PRINT_ERROR_LAST("Expected a list of attributes after '='."); + return poisoned_decl; + } + bool is_cond; bool is_builtin = false; if (!parse_attribute_list(c, &attributes, NULL, decl_needs_prefix(decl) ? &is_builtin : NULL, &is_cond, true)) return poisoned_decl; diff --git a/test/test_suite/attributes/attrdef_err.c3 b/test/test_suite/attributes/attrdef_err.c3 new file mode 100644 index 000000000..376aa247c --- /dev/null +++ b/test/test_suite/attributes/attrdef_err.c3 @@ -0,0 +1,6 @@ + +attrdef @Foo = ; // #error: Expected a list of attributes after +fn void main() +{ + +}