You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
constB=struct {
pubfnfunc() void {
@compileLog(@typeInfo(C).Struct.decls); // .{ .{ .name = "func" } }@compileLog(@hasDecl(C, "func")); // false_=C.func; // ERROR: no member named func
}
};
fnA(comptimeT: type) type {
returnstruct {
pubusingnamespaceT;
};
}
constC=A(B);
pubfnmain() !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.
The text was updated successfully, but these errors were encountered:
LordMZTE
added
the
bug
Observed behavior contradicts documented or intended behavior
label
Nov 5, 2023
LordMZTE
changed the title
Function not visible inside inside itself through generic function with usingnamespace
Function not visible inside itself through generic struct with usingnamespace
Nov 5, 2023
Dependency loops only happen when analyzing a declaration depends on the declaration already being analyzed. A function referencing itself does not require it to be analyzed.
Also encountered this issue on both 0.12.0 and 0.13.0-dev.46+3648d7df1, maybe a simpler reproduction:
conststd=@import("std");
pubconstExample=struct {
usingnamespacestruct {}; // works without this linepubfnfoo() void {
_=Example.foo; // error: struct 'main.Example' has no member named 'foo'
}
};
pubfnmain() !void {
Example.foo();
}
I apologize in advance for the title of this issue.
Zig Version
0.12.0-dev.1396+f6de3ec96
Steps to Reproduce and Observed Behavior
bug.zig
:zig run bug.zig
According to
@typeInfo
, the declarationfunc
is present within C, but according to@hasDecl
, it is not. Schrödinger's declaration!Expected Behavior
The code compiles.
The text was updated successfully, but these errors were encountered: