# fix usingnamespace · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/af8661405b908c0abfc191501a8ad1a59a54e86a)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: af8661405b908c0abfc191501a8ad1a59a54e86a

Requested commit: af8661405b908c0abfc191501a8ad1a59a54e86a

Commit: af8661405b908c0abfc191501a8ad1a59a54e86a

Tree: d76bde495229dc37b7436c547afe5f03aee6b61d

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
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

```

## Parents

- [1d07bbbef23993338b231fbd9d7bbf5a349c5f31](https://git.cafe/gitcafe/zig/commit/1d07bbbef23993338b231fbd9d7bbf5a349c5f31?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/af8661405b908c0abfc191501a8ad1a59a54e86a?format=markdown)
