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

stage2: usingnamespace can create ambiguous reference #12429

Closed
Tracked by #180
slimsag opened this issue Aug 12, 2022 · 0 comments
Closed
Tracked by #180

stage2: usingnamespace can create ambiguous reference #12429

slimsag opened this issue Aug 12, 2022 · 0 comments
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone

Comments

@slimsag
Copy link
Sponsor Contributor

slimsag commented Aug 12, 2022

Zig Version

0.10.0-dev.3551+92568a009

Steps to Reproduce

The following project builds fine with stage1, but not with -fno-stage1. I encountered this trying to build the new mach/gpu library with stage2:

main.zig:

pub const foo = 666;

pub usingnamespace @import("sub.zig");
const sub = @import("sub.zig");

test {
    _ = sub.bar;
}

sub.zig:

const foo = @import("main.zig").foo;

pub const bar = struct {
    bar: u32 = foo,
};

test {
    _ = foo;
}

Expected Behavior

unsure if this should work, or if stage2 is just being more (correctly) strict here.

Actual Behavior

% zig build test -fno-stage1
/Users/slimsag/Desktop/hexops/mach/gpu/test/src/sub.zig:1:32: error: ambiguous reference
const foo = @import("main.zig").foo;
            ~~~~~~~~~~~~~~~~~~~^~~~
/Users/slimsag/Desktop/hexops/mach/gpu/test/src/main.zig:1:5: note: declared here
pub const foo = 666;
~~~~^~~~~~~~~~~~~~~
/Users/slimsag/Desktop/hexops/mach/gpu/test/src/sub.zig:1:1: note: declared here
const foo = @import("main.zig").foo;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@slimsag slimsag added the bug Observed behavior contradicts documented or intended behavior label Aug 12, 2022
slimsag added a commit to hexops/mach that referenced this issue Aug 12, 2022
See ziglang/zig#12429

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
@slimsag slimsag changed the title usingnamespace can create ambiguous reference with stage2 stage2: usingnamespace can create ambiguous reference Aug 12, 2022
@Vexu Vexu added the frontend Tokenization, parsing, AstGen, Sema, and Liveness. label Aug 16, 2022
@Vexu Vexu added this to the 0.10.0 milestone Aug 16, 2022
slimsag added a commit to hexops/mach-gpu that referenced this issue Sep 11, 2022
See ziglang/zig#12429

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
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 frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Projects
None yet
Development

No branches or pull requests

2 participants