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

Union tag gets assigned wrong value in some very specific cases #1381

Hejsil opened this Issue Aug 17, 2018 · 0 comments


None yet
2 participants

Hejsil commented Aug 17, 2018

This is the smallest test case I could come up with:

const B = union(enum) {
    D: u8,
    E: u14,

const A = union(enum) {
    B: B,
    C: u8,

test "" {
    var as =
            A{ .B = B{ .D = 1 }},
            A{ .B = B{ .D = 1 }},

    const a = as[0].B;
Test 1/1 ...access of inactive union field
test.zig:18:20: 0x203094 in ??? (test)
    const a = as[0].B;
  • Remove an element from the array and the test pass
  • Remove C or E and the test pass
  • Change active field of B to E on the first element of the array and the test pass

@andrewrk andrewrk added this to the 0.3.0 milestone Aug 17, 2018

@andrewrk andrewrk added the bug label Aug 17, 2018

@andrewrk andrewrk closed this in dd1338b Sep 11, 2018

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