Skip to content

Wrong diagnostic of import file outside module path when module named build.zig #3249

Description

@trilowy

Zig Version

0.16.0

ZLS Version

0.16.0

Client / Code Editor / Extensions

nvim 0.12.4

Steps to Reproduce and Observed Behavior

Hi, I have a project with one of my module in a file src/command/build.zig.
In it, when I import a file from parent directory @import("../error_handling.zig") I get a wrong diagnostic "import of file outside module path".
I think it has to do with my module named build.zig and mistaken with the one on the root of the project.
No problem reported when I compile and run it with zig.

Expected Behavior

No diagnostic.

Attach ZLS log output

zls.log
info  ( main ): Starting ZLS      0.16.0 @ 'zls'
info  ( main ): Log File:         /home/trilowy/.cache/zls/zls.log (info)
info  (server): Client Info:      Neovim (0.12.4)
info  (server): added Workspace Folder: file:///home/trilowy/workspace/kalamine/src/command (5 files)
info  (server): Set config option 'enable_build_on_save' to true
info  (server): Set config option 'builtin_path' to "/home/trilowy/.cache/zls/builtin.zig"
info  (server): Set config option 'zig_lib_path' to "/nix/store/fvlqxywq2p7h2147m0wdp8g0m38zdprp-zig-0.16.0/lib/zig"
info  (server): Set config option 'zig_exe_path' to "/nix/store/fvlqxywq2p7h2147m0wdp8g0m38zdprp-zig-0.16.0/bin/zig"
info  (server): Set config option 'build_runner_path' to "/home/trilowy/.cache/zls/build_runner/0536d83f23cda18cf0a02d9cd4e6dce4/build_runner.zig"
info  (server): Set config option 'global_cache_path' to "/home/trilowy/.cache/zls"
info  (store ): Loaded build file 'file:///home/trilowy/workspace/kalamine/src/command/build.zig'
warn  ( diag ): zig build-on-save runner exited with with code: 2 and stderr:
build.zig:2:30: error: import of file outside module path
const ParseOptions = @import("../error_handling.zig").ParseOptions;
                             ^~~~~~~~~~~~~~~~~~~~~~~

error (store ): Failed to execute build runner to collect build configuration, command:
cd /home/trilowy/workspace/kalamine/src/command;/nix/store/fvlqxywq2p7h2147m0wdp8g0m38zdprp-zig-0.16.0/bin/zig build --build-runner /home/trilowy/.cache/zls/build_runner/0536d83f23cda18cf0a02d9cd4e6dce4/build_runner.zig --zig-lib-dir /nix/store/fvlqxywq2p7h2147m0wdp8g0m38zdprp-zig-0.16.0/lib/zig
Error: build.zig:2:30: error: import of file outside module path
const ParseOptions = @import("../error_handling.zig").ParseOptions;
                             ^~~~~~~~~~~~~~~~~~~~~~~

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions