diff options
| author | gingerBill <bill@gingerbill.org> | 2021-03-23 22:59:10 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-03-23 22:59:10 +0000 |
| commit | 08f7d3edbe0c530e8565107881fa2443a477b779 (patch) | |
| tree | db101ef628d8013103149277192eece60ecaabbe /src/check_type.cpp | |
| parent | c62980eaeaf36a76c801a8f2745a29c953d6b88a (diff) | |
Allow `$` in polymorphic record parameter fields (but disallow mixing)
Diffstat (limited to 'src/check_type.cpp')
| -rw-r--r-- | src/check_type.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp index eb2891cb7..3eada163c 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -152,10 +152,12 @@ void check_struct_fields(CheckerContext *ctx, Ast *node, Array<Entity *> *fields for_array(j, p->names) { Ast *name = p->names[j]; - if (!ast_node_expect(name, Ast_Ident)) { + if (!ast_node_expect2(name, Ast_Ident, Ast_PolyType)) { continue; } - + if (name->kind == Ast_PolyType) { + name = name->PolyType.type; + } Token name_token = name->Ident.token; Entity *field = alloc_entity_field(ctx->scope, name_token, type, is_using, field_src_index); @@ -464,9 +466,12 @@ void check_struct_type(CheckerContext *ctx, Type *struct_type, Ast *node, Array< Scope *scope = ctx->scope; for_array(j, p->names) { Ast *name = p->names[j]; - if (!ast_node_expect(name, Ast_Ident)) { + if (!ast_node_expect2(name, Ast_Ident, Ast_PolyType)) { continue; } + if (name->kind == Ast_PolyType) { + name = name->PolyType.type; + } Entity *e = nullptr; Token token = name->Ident.token; @@ -680,9 +685,12 @@ void check_union_type(CheckerContext *ctx, Type *union_type, Ast *node, Array<Op Scope *scope = ctx->scope; for_array(j, p->names) { Ast *name = p->names[j]; - if (!ast_node_expect(name, Ast_Ident)) { + if (!ast_node_expect2(name, Ast_Ident, Ast_PolyType)) { continue; } + if (name->kind == Ast_PolyType) { + name = name->PolyType.type; + } Entity *e = nullptr; Token token = name->Ident.token; |