From 5b279434986b18d07ceec217c5c402a589ccc0b4 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 10 Nov 2019 21:58:05 -0500 Subject: implement anon struct literal syntax This implements stage1 parser support for anonymous struct literal syntax (see #685), as well as semantic analysis support for anonymous struct literals and anonymous list literals (see #208). The semantic analysis works when there is a type coercion in the result location; inferring the struct type based on the values in the literal is not implemented yet. Also remaining to do is zig fmt support for this new syntax and documentation updates. --- src/ast_render.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/ast_render.cpp') diff --git a/src/ast_render.cpp b/src/ast_render.cpp index c016f629d1..34cbed245a 100644 --- a/src/ast_render.cpp +++ b/src/ast_render.cpp @@ -821,7 +821,9 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) { break; } case NodeTypeContainerInitExpr: - render_node_ungrouped(ar, node->data.container_init_expr.type); + if (node->data.container_init_expr.type != nullptr) { + render_node_ungrouped(ar, node->data.container_init_expr.type); + } if (node->data.container_init_expr.kind == ContainerInitKindStruct) { fprintf(ar->f, "{\n"); ar->indent += ar->indent_size; -- cgit v1.2.3