-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone
Description
I apologize in advance for the title of this issue.
Zig Version
0.12.0-dev.1396+f6de3ec96
Steps to Reproduce and Observed Behavior
- Create a file
bug.zig:
const B = struct {
pub fn func() void {
@compileLog(@typeInfo(C).Struct.decls); // .{ .{ .name = "func" } }
@compileLog(@hasDecl(C, "func")); // false
_ = C.func; // ERROR: no member named func
}
};
fn A(comptime T: type) type {
return struct {
pub usingnamespace T;
};
}
const C = A(B);
pub fn main() !void {
C.func();
}zig run bug.zig
bug.zig:5:14: error: struct 'bug.A(bug.B)' has no member named 'func'
_ = C.func; // ERROR: no member named func
~^~~~~
bug.zig:10:12: note: struct declared here
return struct {
^~~~~~
referenced by:
main: bug.zig:18:6
callMain: /home/lordmzte/.local/share/zupper/installs/master/lib/std/start.zig:581:32
remaining reference traces hidden; use '-freference-trace' to see all reference traces
Compile Log Output:
@as([]const builtin.Type.Declaration, .{ .{.name = "func"} })
@as(bool, false)
According to @typeInfo, the declaration func is present within C, but according to @hasDecl, it is not. Schrödinger's declaration!
Expected Behavior
The code compiles.
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.