Deprecate enum field access
This commit is contained in:
parent
8c3d1e4066
commit
7a741e65e6
10
compile.c
10
compile.c
@ -1864,16 +1864,6 @@ CORD compile(env_t *env, ast_t *ast)
|
||||
}
|
||||
code_err(ast, "The field '%s' is not a valid field name of %T", f->field, value_t);
|
||||
}
|
||||
case EnumType: {
|
||||
auto enum_ = Match(value_t, EnumType);
|
||||
for (tag_t *tag = enum_->tags; tag; tag = tag->next) {
|
||||
if (streq(tag->name, f->field)) {
|
||||
CORD fielded = compile_to_pointer_depth(env, f->fielded, 0, false);
|
||||
return CORD_asprintf("$tagged(%r, %r%s, %s)", fielded, env->file_prefix, enum_->name, f->field);
|
||||
}
|
||||
}
|
||||
code_err(ast, "The field '%s' is not a valid field name of %T", f->field, value_t);
|
||||
}
|
||||
case TableType: {
|
||||
if (streq(f->field, "keys")) {
|
||||
return CORD_all("({ table_t *t = ", compile_to_pointer_depth(env, f->fielded, 1, false), ";\n"
|
||||
|
8
types.c
8
types.c
@ -497,14 +497,6 @@ type_t *get_field_type(type_t *t, const char *field_name)
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
case EnumType: {
|
||||
auto e = Match(t, EnumType);
|
||||
for (tag_t *tag = e->tags; tag; tag = tag->next) {
|
||||
if (streq(field_name, tag->name))
|
||||
return Type(PointerType, .pointed=tag->type, .is_optional=true, .is_readonly=true);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
case TableType: {
|
||||
if (streq(field_name, "keys"))
|
||||
return Type(ArrayType, Match(t, TableType)->key_type);
|
||||
|
Loading…
Reference in New Issue
Block a user