From affb722b23deb1401ffd5153368ebaad791e8533 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Mon, 23 Jun 2025 14:45:16 +0200 Subject: [PATCH] @tag didn't work with members #2236. --- releasenotes.md | 3 ++- src/compiler/sema_decls.c | 1 + test/test_suite/union/member_tag.c3 | 13 +++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 test/test_suite/union/member_tag.c3 diff --git a/releasenotes.md b/releasenotes.md index 3d4c247a2..f011644cc 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -61,7 +61,8 @@ - Overload resolution fixes to inline typedef #2226. - `math::overflow_*` wrappers incorrectly don't allow distinct integers #2221. - Compiler segfault when using distinct type in attribute imported from other module #2234. -- Assert casting bitstruct to short/char #2237 +- Assert casting bitstruct to short/char #2237. +- @tag didn't work with members #2236. ### Stdlib changes - Deprecate `String.is_zstr` and `String.quick_zstr` #2188. diff --git a/src/compiler/sema_decls.c b/src/compiler/sema_decls.c index 3c6d536c0..7981bfed7 100755 --- a/src/compiler/sema_decls.c +++ b/src/compiler/sema_decls.c @@ -3594,6 +3594,7 @@ static bool sema_analyse_attributes_inner(SemaContext *context, ResolvedAttrData static bool sema_analyse_attributes(SemaContext *context, Decl *decl, Attr **attrs, AttributeDomain domain, bool *erase_decl) { + if (decl->resolved_attributes) return true; ResolvedAttrData data = { .tags = NULL, .overload = INVALID_SPAN }; if (!sema_analyse_attributes_inner(context, &data, decl, attrs, domain, NULL, erase_decl)) return false; if (*erase_decl) return true; diff --git a/test/test_suite/union/member_tag.c3 b/test/test_suite/union/member_tag.c3 new file mode 100644 index 000000000..acbca38bc --- /dev/null +++ b/test/test_suite/union/member_tag.c3 @@ -0,0 +1,13 @@ +struct Test +{ + union a @tag("a", 1) + { + int x; + } +} + +fn int main(String[] args) +{ + $assert(Test.a.has_tagof("a")); // Error: Compile time assert failed. + return 0; +} \ No newline at end of file