diff --git a/releasenotes.md b/releasenotes.md index 6bdd4ce13..d86cd820f 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -28,6 +28,7 @@ - `overflow_*` vector ops now correctly return a bool vector. - Regression vector ABI: npot vectors would load incorrectly from pointers and other things. #2576 - Using `defer catch` with a (void), would cause an assertion. #2580 +- Fix decl attribute in the wrong place causing an assertion. #2581 ### Stdlib changes diff --git a/src/compiler/parse_global.c b/src/compiler/parse_global.c index a498c4580..3f7bf2d5e 100644 --- a/src/compiler/parse_global.c +++ b/src/compiler/parse_global.c @@ -1964,7 +1964,8 @@ static inline Decl *parse_typedef_declaration(ParseContext *c) } else { - RETURN_PRINT_ERROR_HERE("Expected only attribute '@align'."); + PRINT_ERROR_HERE("Expected only attribute '@align' here, if you want to add an attribute to the typedef itself, place it before the '='."); + return poisoned_decl; } } RANGE_EXTEND_PREV(decl); diff --git a/test/test_suite/distinct/decl_with_attribute_wrong_place.c3 b/test/test_suite/distinct/decl_with_attribute_wrong_place.c3 new file mode 100644 index 000000000..d2cdcc2cb --- /dev/null +++ b/test/test_suite/distinct/decl_with_attribute_wrong_place.c3 @@ -0,0 +1,5 @@ +module foo; + +typedef Int = int @structlike; // #error: Expected only attribute + +fn int main() => 0; \ No newline at end of file