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

@tagName behaves incorrectly when enums have non-default values at runtime #1080

tgschultz opened this Issue Jun 8, 2018 · 1 comment


None yet
3 participants

tgschultz commented Jun 8, 2018

const std = @import("std");

const TestEnum = enum(u32) {
    One = 64,
    Two = 128,

pub fn main() void {
    var test_enum = TestEnum.One;
    std.debug.warn("{}\n", @tagName(test_enum));

output, as from

index out of bounds
�[37;1m/home/runner/.code.tio:10:28�[0m: �[2m0x2200da in ??? (.code)�[0m
    std.debug.warn("{}\n", @tagName(test_enum));
�[37;1m/opt/zig/lib/zig/std/special/bootstrap.zig:86:22�[0m: �[2m0x220089 in ??? (.code)�[0m
�[37;1m/opt/zig/lib/zig/std/special/bootstrap.zig:70:20�[0m: �[2m0x220029 in ??? (.code)�[0m
    return callMain();
�[37;1m/opt/zig/lib/zig/std/special/bootstrap.zig:64:39�[0m: �[2m0x21fd9f in ??? (.code)�[0m
    std.os.posix.exit(callMainWithArgs(argc, argv, envp));
�[37;1m/opt/zig/lib/zig/std/special/bootstrap.zig:39:5�[0m: �[2m0x21fc40 in ??? (.code)�[0m
/srv/wrappers/zig: line 4:  2156 Aborted                 (core dumped) ./.bin.tio "$@" < .input.tio

Real time: 0.665 s
User time: 0.479 s
Sys. time: 0.155 s
CPU share: 95.23 %
Exit code: 134

This comment has been minimized.


tiehuis commented Jun 8, 2018

Related to #976.

@andrewrk andrewrk added this to the 0.3.0 milestone Jun 9, 2018

@andrewrk andrewrk added the bug label Jun 9, 2018

@andrewrk andrewrk closed this in 03c16c6 Jun 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment