Skip to content
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

Assigning anon struct to union variable causes trace/breakpoint trap #19890

Closed
chung-leong opened this issue May 7, 2024 · 2 comments
Closed
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@chung-leong
Copy link

chung-leong commented May 7, 2024

Zig Version

0.13.0-dev.73+db890dbae

Steps to Reproduce and Observed Behavior

Run test on the following code:

const BareUnion = union {
    dog: i32,
    cat: i32,
};
var bare_union: BareUnion = .{ .dog = 123 };

fn useDog() void {
    bare_union = .{ .dog = 777 };
}

test "useDog" {
    useDog();
}

Compilation bails out with the following message:

Trace/breakpoint trap (core dumped)

No error when the following variants are used instead:

fn useDog() void {
    bare_union = BareUnion{ .dog = 777 };
}

fn useDog() void {
    const c = .{ .dog = 777 };
    bare_union = c;
}

Expected Behavior

No error

@chung-leong chung-leong added the bug Observed behavior contradicts documented or intended behavior label May 7, 2024
@xdBronch
Copy link
Contributor

xdBronch commented May 7, 2024

looks like duplicate of #19832

@chung-leong
Copy link
Author

I believe so.

@Vexu Vexu closed this as not planned Won't fix, can't repro, duplicate, stale May 8, 2024
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
Projects
None yet
Development

No branches or pull requests

3 participants