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

"root" module is real root file when building executable, but is test_runner when testing #17109

Closed
iacore opened this issue Sep 10, 2023 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@iacore
Copy link
Contributor

iacore commented Sep 10, 2023

Zig Version

0.11.0

Steps to Reproduce and Observed Behavior

  1. Create a zig file
pub const a = 1;
const b = @import("root").a;

pub fn main() void {
    _ = b;
}

test {
    _ = b;
}
  1. Run zig build-exe hi.zig (works!)
  2. Run zig test hi.zig (error)
hi.zig:2:26: error: root struct of file 'test_runner' has no member named 'a'
const b = @import("root").a;
          ~~~~~~~~~~~~~~~^~
referenced by:
    test_0: hi.zig:9:9
    remaining reference traces hidden; use '-freference-trace' to see all reference traces

Expected Behavior

I think they should behave the same.

Currently std.log changes behavior in test mode. Maybe it can only be done by swapping out the root module.

@iacore iacore added the bug Observed behavior contradicts documented or intended behavior label Sep 10, 2023
@Vexu
Copy link
Member

Vexu commented Sep 11, 2023

Rejected as a proposal in #12201

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

No branches or pull requests

2 participants