structs can have fields with type var

behavior tests passing now
This commit is contained in:
Andrew Kelley
2019-11-23 17:51:37 -05:00
parent 7597735bad
commit f25182f46d
8 changed files with 97 additions and 61 deletions

View File

@@ -848,7 +848,12 @@ static AstNode *ast_parse_container_field(ParseContext *pc) {
AstNode *type_expr = nullptr;
if (eat_token_if(pc, TokenIdColon) != nullptr) {
type_expr = ast_expect(pc, ast_parse_type_expr);
Token *var_tok = eat_token_if(pc, TokenIdKeywordVar);
if (var_tok != nullptr) {
type_expr = ast_create_node(pc, NodeTypeVarFieldType, var_tok);
} else {
type_expr = ast_expect(pc, ast_parse_type_expr);
}
}
AstNode *align_expr = ast_parse_byte_align(pc);
AstNode *expr = nullptr;
@@ -3163,6 +3168,7 @@ void ast_visit_node_children(AstNode *node, void (*visit)(AstNode **, void *cont
visit_field(&node->data.suspend.block, visit, context);
break;
case NodeTypeEnumLiteral:
case NodeTypeVarFieldType:
break;
}
}