Skip to content

Commit e8da0d6

Browse files
fix(compiler): tag method error messages showed wrong function names;
corrected to `has_tag`/`get_tag`
1 parent 71bc284 commit e8da0d6

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/compiler/sema_expr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3721,7 +3721,7 @@ static inline bool sema_expr_analyse_typecall(SemaContext *context, Expr *expr)
37213721
Expr **args = expr->call_expr.arguments;
37223722
unsigned arg_count = vec_size(args);
37233723
bool is_has = tag->type_call_expr.property == TYPE_PROPERTY_HAS_TAG;
3724-
const char *name = is_has ? "has_tagof" : "tagof";
3724+
const char *name = is_has ? "has_tag" : "get_tag";
37253725
if (arg_count != 1) RETURN_SEMA_ERROR(expr, "Expected a single string argument to '%s'.", name);
37263726
Expr *key = args[0];
37273727
if (!sema_analyse_expr_rvalue(context, key)) return false;
@@ -6494,7 +6494,7 @@ static bool sema_expr_rewrite_to_type_property(SemaContext *context, Expr *expr,
64946494
case TYPE_PROPERTY_GET_TAG:
64956495
if (!type_is_user_defined(type))
64966496
{
6497-
RETURN_SEMA_ERROR(expr, "'tagof' is not defined for builtin types like %s.", type_quoted_error_string(type));
6497+
RETURN_SEMA_ERROR(expr, "'get_tag' is not defined for builtin types like %s.", type_quoted_error_string(type));
64986498
}
64996499
FALLTHROUGH;
65006500
case TYPE_PROPERTY_HAS_TAG:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
struct MyStruct { int a @tag("a", 0); }
2+
fn void main(String[] args) {
3+
$foreach $member : MyStruct::members:
4+
$member.has_tag("a", "a"); // #error: Expected a single string argument to 'has_tag'.
5+
$member.get_tag("a", "a"); // #error: Expected a single string argument to 'get_tag'.
6+
$endforeach
7+
}
8+
fn void test_builtin() {
9+
int::get_tag("key"); // #error: 'get_tag' is not defined for builtin types like 'int'.
10+
}

0 commit comments

Comments
 (0)