Skip to content

compiler includes internal indices in type and function names #24116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mlugg opened this issue Jun 7, 2025 · 1 comment
Open

compiler includes internal indices in type and function names #24116

mlugg opened this issue Jun 7, 2025 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone

Comments

@mlugg
Copy link
Member

mlugg commented Jun 7, 2025

Zig Version

0.15.0-dev.762+3208c80f2

Steps to Reproduce and Observed Behavior

Declare a type in a non-trivial way and look at its name:

const S = blk: {
    break :blk struct {};
};
comptime {
    @compileLog(@typeName(S));
}
$ zig build-obj repro.zig
Compile Log Output:
@as(*const [19:0]u8, "repro.S__struct_213")

Or, instantiate a generic function and look at its name in the binary:

fn generic(comptime _: u32) void {}
export fn foo() void {
    generic(0);
}
$ zig build-obj repro.zig && nm repro.o | grep generic
0000000000000040 t repro.generic__anon_494

These numbers are indices into the compiler's InternPool.

Expected Behavior

The names ideally should not depend on details of compiler internals. We should aim to generate descriptive names.

If it turns out there isn't a good alternative way to generate unique names, then at the very least, these type names with random numbers in them shouldn't be printed in compile errors which mention the types. It would be relatively easy for us to give the type a different name when printing it.

#24115 tracks missing test coverage which was deleted because it depended on these names.

@mlugg mlugg added this to the 0.15.0 milestone Jun 7, 2025
@mlugg mlugg added bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness. labels Jun 7, 2025
@andrewrk
Copy link
Member

andrewrk commented Jun 7, 2025

Missing coverage tracked by #24115

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Projects
None yet
Development

No branches or pull requests

2 participants