Correctly error on @attrdef Foo = ;.

This commit is contained in:
Christoffer Lerno
2025-05-14 12:15:42 +02:00
parent 50b4d7aa35
commit 36eb650228
3 changed files with 13 additions and 0 deletions

View File

@@ -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`

View File

@@ -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;

View File

@@ -0,0 +1,6 @@
attrdef @Foo = ; // #error: Expected a list of attributes after
fn void main()
{
}