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/ir.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/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 579875dc3c..be7a8e2e51 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -8430,7 +8430,7 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop switch (node->type) { case NodeTypeStructValueField: case NodeTypeParamDecl: - case NodeTypeUse: + case NodeTypeUsingNamespace: case NodeTypeSwitchProng: case NodeTypeSwitchRange: case NodeTypeStructField: @@ -17847,6 +17847,7 @@ static IrInstruction *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_ switch (tld->id) { case TldIdContainer: case TldIdCompTime: + case TldIdUsingNamespace: zig_unreachable(); case TldIdVar: { |
