# AstGen: detect and error on files included in multiple packages · gitcafe/zig

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

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

Visibility: public

Requested revision: 5f9186d0ce78ce1eb7db9634849b38d2e90d071e

Requested commit: 5f9186d0ce78ce1eb7db9634849b38d2e90d071e

Commit: 5f9186d0ce78ce1eb7db9634849b38d2e90d071e

Tree: ab46e6e77fe60874eb9f52779196ecbd8e4deabc

Author: mlugg

Committer: mlugg

## Message

```
AstGen: detect and error on files included in multiple packages

Previously, if a source file was referenced from multiple packages, it
just became owned by the first one AstGen happened to reach; this was a
problem, because it could lead to inconsistent behaviour in the compiler
based on a race condition. This could be fixed by just analyzing such
files multiple times - however, it was pointed out by Andrew that it
might make more sense to enforce files being part of at most a single
package. Having a file in multiple packages would not only impact
compile times (due to Sema having to run multiple times on potentially a
lot of code) but is also a confusing anti-pattern which more often than
not is a mistake on the part of the user.

Resolves: #13662

```

## Parents

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

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