-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed as not planned
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavior
Description
Zig Version
0.15.0-dev.64+2a4e06bcb
Steps to Reproduce and Observed Behavior
Compiling and running the following source will reproduce the unexpected behaviour:
const std = @import("std");
const Foo = struct {f32};
const Bar = struct {f: f32};
pub fn main() void {
const foo = @typeName(Foo);
const bar = @typeName(Bar);
std.debug.print("{s}\n{s}\n", .{foo, bar});
}
Output when run:
struct { f32 }
test.Bar
Expected Behavior
The tuple struct should be named, just like a regular struct. Expected output:
test.Foo
test.Bar
I first noticed this bug in 0.14. I would expect that @typeName
returns the name of the tuple, instead of its definition. Some motivation as to why this matters for me: I'm writing an ECS and I want the end-user to be able to use any type for a component. Thus, I need an ID that is unique per-type at runtime. Since Zig does not have a type ID builtin, I figured @typeName
should do the trick. This works perfectly for structs, but not for tuple structs.
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavior