diff --git a/releasenotes.md b/releasenotes.md index 335dafa9b..b5f46416d 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -10,8 +10,9 @@ - Assert triggered when casting from `int[2]` to `uint[2]` #2115 - Assert when a macro with compile time value is discarded, e.g. `foo();` where `foo()` returns an untyped list. #2117 - Fix stringify for compound initializers #2120. -- Fix No index OOB check for `[:^n]` #2123 -- Fix regression in Time diff due to operator overloading #2124 +- 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. ### 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 03f024a78..63f22800e 100644 --- a/src/compiler/parse_global.c +++ b/src/compiler/parse_global.c @@ -2209,7 +2209,7 @@ static inline Decl *parse_attrdef(ParseContext *c) Decl *decl = decl_new(DECL_ATTRIBUTE, symstr(c), c->span); - advance_and_verify(c, TOKEN_AT_TYPE_IDENT); + TRY_CONSUME_OR_RET(TOKEN_AT_TYPE_IDENT, "Expected an attribute type name, like '@MyAttr'.", poisoned_decl); if (try_consume(c, TOKEN_LPAREN)) { diff --git a/test/test_suite/attributes/illegal_attr.c3 b/test/test_suite/attributes/illegal_attr.c3 new file mode 100644 index 000000000..bbbd2e2dc --- /dev/null +++ b/test/test_suite/attributes/illegal_attr.c3 @@ -0,0 +1,9 @@ + +attrdef @FOO = @test; // #error: Expected an +attrdef 1 = @test; // #error: Expected an +attrdef @foo = @test; // #error: Expected an +attrdef foo = @test; // #error: Expected an +attrdef $foo = @test; // #error: Expected an +attrdef #foo = @test; // #error: Expected an +attrdef "foo" = @test; // #error: Expected an +attrdef 'f' = @test; // #error: Expected an \ No newline at end of file