Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@import ZON not picking up changed files #22746

Closed
MasonRemaley opened this issue Feb 4, 2025 · 0 comments
Closed

@import ZON not picking up changed files #22746

MasonRemaley opened this issue Feb 4, 2025 · 0 comments
Labels
bug Observed behavior contradicts documented or intended behavior
Milestone

Comments

@MasonRemaley
Copy link
Contributor

Zig Version

0.14.0-dev.3046+08d661fcf

Steps to Reproduce and Observed Behavior

If you @import a ZON file, run your program, and then change the ZON file the cached ZON data isn't invalidated.

I'm looking at fixing this now, tracking here to acknowledge that the issue is known.

Expected Behavior

Changes to the ZON file should be picked up when the compiler is rerun.

@MasonRemaley MasonRemaley added the bug Observed behavior contradicts documented or intended behavior label Feb 4, 2025
@mlugg mlugg added this to the 0.14.0 milestone Feb 4, 2025
mlugg added a commit to mlugg/zig that referenced this issue Feb 4, 2025
This came with a big cleanup to `Zcu.PerThread.updateFile` (formerly
`astGenFile`).

Also, change how the cache manifest works for files in the import table.
Instead of being added to the manifest when we call `semaFile` on them,
we iterate the import table after running the AstGen workers and add all
the files to the cache manifest then.

The downside is that this is a bit more eager to include files in the
manifest; in particular, files which are imported but not actually
referenced are now included in analysis. So, for instance, modifying any
standard library file will invalidate all Zig compilations using that
standard library, even if they don't use that file.

The original motivation here was simply that the old logic in `semaFile`
didn't translate nicely to ZON. However, it turns out to actually be
necessary for correctness. Because `@import("foo.zig")` is an
AstGen-level error if `foo.zig` does not exist, we need to invalidate
the cache when an imported but unreferenced file is removed to make sure
this error is triggered when it needs to be.

Resolves: ziglang#22746
@mlugg mlugg closed this as completed in 55a2e53 Feb 5, 2025
devknoll pushed a commit to devknoll/zig that referenced this issue Feb 10, 2025
This came with a big cleanup to `Zcu.PerThread.updateFile` (formerly
`astGenFile`).

Also, change how the cache manifest works for files in the import table.
Instead of being added to the manifest when we call `semaFile` on them,
we iterate the import table after running the AstGen workers and add all
the files to the cache manifest then.

The downside is that this is a bit more eager to include files in the
manifest; in particular, files which are imported but not actually
referenced are now included in analysis. So, for instance, modifying any
standard library file will invalidate all Zig compilations using that
standard library, even if they don't use that file.

The original motivation here was simply that the old logic in `semaFile`
didn't translate nicely to ZON. However, it turns out to actually be
necessary for correctness. Because `@import("foo.zig")` is an
AstGen-level error if `foo.zig` does not exist, we need to invalidate
the cache when an imported but unreferenced file is removed to make sure
this error is triggered when it needs to be.

Resolves: ziglang#22746
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants