Skip to content

assertion failed #4528

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

Closed
markfirmware opened this issue Feb 23, 2020 · 2 comments
Closed

assertion failed #4528

markfirmware opened this issue Feb 23, 2020 · 2 comments
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Milestone

Comments

@markfirmware
Copy link
Contributor

markfirmware commented Feb 23, 2020

pub fn main() void {
    var data: u8 = 0;
    const x = .{
        if (data != 0) ""[0..] else switch (@truncate(u1, data)) {
            0 => "up"[0 ..],
            1 => "down",
        },
    };
}

0.5.0+0cd89e917

when analyzing /root/github.com/ziglang/zig/defect.zig:4:38: assertion failed. This is a bug in the Zig compiler.
Unable to dump stack trace: debug info stripped
@daurnimator daurnimator added bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend. labels Feb 23, 2020
@andrewrk andrewrk added this to the 0.7.0 milestone Feb 29, 2020
@xackus
Copy link
Contributor

xackus commented May 10, 2020

Results in an error on e79d7e0:

test.zig:5:22: error: expected type '*const [0:0]u8', found '*const [2:0]u8'
            0 => "up"[0 ..],
                     ^
test.zig:5:22: note: pointer type child '[2:0]u8' cannot cast into pointer type child '[0:0]u8'
            0 => "up"[0 ..],
                     ^

@Vexu
Copy link
Member

Vexu commented May 10, 2020

Still gives an assertion failure if you fix the type error:

pub fn main() void {
    var data: u8 = 0;
    const x = .{
        @as([]const u8, if (data != 0) "" else switch (@truncate(u1, data)) {
            0 => "up",
            1 => "down",
        }),
    };
}

// when analyzing a.zig:24:40: assertion failed. This is a bug in the Zig compiler.

@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Aug 13, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 Nov 6, 2020
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 May 19, 2021
Vexu added a commit to Vexu/zig that referenced this issue Dec 31, 2022
Vexu added a commit to Vexu/zig that referenced this issue Dec 31, 2022
@andrewrk andrewrk modified the milestones: 0.12.0, 0.11.0 Jan 1, 2023
TUSF pushed a commit to TUSF/zig that referenced this issue May 9, 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 stage1 The process of building from source via WebAssembly and the C backend.
Projects
None yet
Development

No branches or pull requests

5 participants