Skip to content

@compileLog output includes redundant @as #21776

@xdBronch

Description

@xdBronch

Zig Version

0.14.0-dev.1951+857383689

Steps to Reproduce and Observed Behavior

comptime {
    const a: u32 = 0;
    @compileLog(&a);
    @compileLog(@as([*]const u8, @ptrFromInt(1)));
}
Compile Log Output:
@as(*const u32, @as(u32, 0))
@as([*]const u8, @as([*]const u8, @ptrFromInt(1)).*)

@compileLog seems to try to represent the value being pointed to rather than the pointer but in both cases it ends up being wrong. the second one also dereferences a many-item pointer

Expected Behavior

i think the second one should just be @as([*]const u8, @ptrFromInt(1)), not particularly useful but correct, not any worse than current. the first one maybe should show @as(*const u32, &a)? im not sure if that would really be useful, @as(*const u32, &@as(u32, 0)) could work if we wanted it to be a little more descriptive so it'd show the underlying value for vars

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions