mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
@tag was not allowed to repeat.
This commit is contained in:
@@ -60,6 +60,7 @@
|
||||
- Failed to find subscript overloading on optional values.
|
||||
- `Socket.get_option` didn't properly call `getsockopt`, and `getsockopt` had an invalid signature.
|
||||
- Taking the address of a label would cause a crash. #2430
|
||||
- `@tag` was not allowed to repeat.
|
||||
|
||||
### Stdlib changes
|
||||
- Add `==` to `Pair`, `Triple` and TzDateTime. Add print to `Pair` and `Triple`.
|
||||
|
||||
@@ -1287,12 +1287,14 @@ static inline bool parse_attribute_list(ParseContext *c, Attr ***attributes_ref,
|
||||
*visibility_ref = visibility = parsed_visibility;
|
||||
continue;
|
||||
}
|
||||
if (attr->attr_kind == ATTRIBUTE_TAG) goto ADD;
|
||||
}
|
||||
const char *name = attr->name;
|
||||
FOREACH(Attr *, other_attr, *attributes_ref)
|
||||
{
|
||||
if (other_attr->name == name) RETURN_PRINT_ERROR_AT(false, attr, "Repeat of attribute '%s' here.", name);
|
||||
}
|
||||
ADD:
|
||||
vec_add(*attributes_ref, attr);
|
||||
if (use_comma && !try_consume(c, TOKEN_COMMA)) break;
|
||||
}
|
||||
|
||||
12
test/test_suite/compile_time_introspection/tag_multiple.c3t
Normal file
12
test/test_suite/compile_time_introspection/tag_multiple.c3t
Normal file
@@ -0,0 +1,12 @@
|
||||
struct Foo @tag("a", true) @tag("b", false)
|
||||
{
|
||||
int a;
|
||||
}
|
||||
fn void main()
|
||||
{
|
||||
Foo x;
|
||||
$assert(Foo.has_tagof("b"));
|
||||
$assert(Foo.has_tagof("a"));
|
||||
$assert(Foo.tagof("a"));
|
||||
$assert(!Foo.tagof("b"));
|
||||
}
|
||||
Reference in New Issue
Block a user