Closed
Description
Zig Version
0.9.1
Steps to Reproduce
Case 1:
fn reflect(comptime entity: anytype) void {
@compileLog(@typeInfo(entity).Struct.decls[0].name);
@compileLog(@typeInfo(entity).Struct.decls[0].data.Fn.arg_names);
@compileLog(@typeInfo(entity).Struct.decls[1].name);
@compileLog(@typeInfo(entity).Struct.decls[1].data.Fn.arg_names);
}
pub const Foo = struct {
pub fn init(a: u32, b: u64) Foo {
_ = a;
_ = b;
return Foo{};
}
pub fn foo(self: *Foo, c: u32) void {
_ = self;
_ = c;
}
};
pub fn main() !void {
reflect(Foo);
}
Case 2:
fn reflect(comptime entity: anytype) void {
@compileLog(@typeInfo(entity).Struct.decls[0].name);
@compileLog(@typeInfo(entity).Struct.decls[0].data.Fn.arg_names);
@compileLog(@typeInfo(entity).Struct.decls[1].name);
@compileLog(@typeInfo(entity).Struct.decls[1].data.Fn.arg_names);
}
pub const Foo = struct {
pub fn init(a: u32, b: u64) Foo {
reflect(@This());
_ = a;
_ = b;
return Foo{};
}
pub fn foo(self: *Foo, c: u32) void {
_ = self;
_ = c;
}
};
pub fn main() !void {
var foo = Foo.init(1, 2);
_ = foo;
}
Expected Behavior
Both cases:
| "init"
| []const []const u8{"a","b"}
| "foo"
| []const []const u8{"self","c"}
Actual Behavior
Case 1:
| "init"
| []const []const u8{}
| "foo"
| []const []const u8{}
Case 2:
| "init"
| []const []const u8{"a","b"}
| "foo"
| []const []const u8{}
This issue appears to be similar to the later comments in #8259, but that issue was closed in March. Unsure how the closing comment applies here.