diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-07-19 16:56:44 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-07-19 16:56:44 -0400 |
| commit | af8661405b908c0abfc191501a8ad1a59a54e86a (patch) | |
| tree | d76bde495229dc37b7436c547afe5f03aee6b61d /src/ast_render.cpp | |
| parent | 1d07bbbef23993338b231fbd9d7bbf5a349c5f31 (diff) | |
| download | zig-af8661405b908c0abfc191501a8ad1a59a54e86a.tar.gz zig-af8661405b908c0abfc191501a8ad1a59a54e86a.zip | |
fix usingnamespace
It used to be that usingnamespace was only allowed at top level. This
made it OK to put the state inside the AST node data structure. However,
now usingnamespace can occur inside any aggregate data structure, and
therefore the state must be in the TopLevelDeclaration rather than in
the AST node.
There were two other problems with the usingnamespace implementation:
* It was passing the wrong destination ScopeDecl, so it could cause an
incorrect error such as "import of file outside package path".
* When doing `usingnamespace` on a file that already had
`pub usingnamespace` in it would "steal" the usingnamespace, causing
incorrect "use of undeclared identifier" errors in the target file.
closes #2632
closes #2580
Diffstat (limited to 'src/ast_render.cpp')
| -rw-r--r-- | src/ast_render.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/ast_render.cpp b/src/ast_render.cpp index 154803f884..fe131ab65f 100644 --- a/src/ast_render.cpp +++ b/src/ast_render.cpp @@ -193,8 +193,8 @@ static const char *node_type_str(NodeType node_type) { return "Symbol"; case NodeTypePrefixOpExpr: return "PrefixOpExpr"; - case NodeTypeUse: - return "Use"; + case NodeTypeUsingNamespace: + return "UsingNamespace"; case NodeTypeBoolLiteral: return "BoolLiteral"; case NodeTypeNullLiteral: @@ -791,7 +791,7 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) { AstNode *decls_node = node->data.container_decl.decls.at(decl_i); render_node_grouped(ar, decls_node); - if (decls_node->type == NodeTypeUse || + if (decls_node->type == NodeTypeUsingNamespace || decls_node->type == NodeTypeVariableDeclaration || decls_node->type == NodeTypeFnProto) { @@ -1170,7 +1170,7 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) { case NodeTypeParamDecl: case NodeTypeTestDecl: case NodeTypeStructField: - case NodeTypeUse: + case NodeTypeUsingNamespace: zig_panic("TODO more ast rendering"); } } |
