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

Assertion failed in type_has_bits #3994

Closed
daurnimator opened this issue Dec 29, 2019 · 0 comments · Fixed by #4009
Closed

Assertion failed in type_has_bits #3994

daurnimator opened this issue Dec 29, 2019 · 0 comments · Fixed by #4009
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Milestone

Comments

@daurnimator
Copy link
Contributor

const std = @import("std");
const testing = std.testing;

test "weird failure" {
    const MyIntWrapper = struct {
        const Self = @This();

        x: i32,

        pub fn create() anyerror!Self {
            return Self{
                .x = 42,
            };
        }
    };

    testing.expectEqual(MyIntWrapper{ .x = 42 }, try MyIntWrapper.create());
}
#10 0x0000555555712d4d in stage2_panic (ptr=0x55555593b1a4 "", len=0) at stage1.zig:33
#11 0x00005555556d1932 in zig_panic (format=0x55555593b240 "Assertion failed at %s:%d in %s. This is a bug in the Zig compiler.") at /home/daurnimator/src/zig/src/util.cpp:20
#12 0x00005555556d20aa in zig_assert (ok=false, file=0x55555593b3c0 "/home/daurnimator/src/zig/src/analyze.cpp", line=5473, func=0x55555593d64e "type_has_bits") at /home/daurnimator/src/zig/src/util.hpp:58
#13 0x00005555556e3c13 in type_has_bits (type_entry=0x555555df5f50) at /home/daurnimator/src/zig/src/analyze.cpp:5473
#14 0x00005555555fd932 in ir_render_unwrap_err_payload (g=0x555555a23af0, executable=0x555555addb00, instruction=0x555555dfa770) at /home/daurnimator/src/zig/src/codegen.cpp:5568
#15 0x000055555560068c in ir_render_instruction (g=0x555555a23af0, executable=0x555555addb00, instruction=0x555555dfa770) at /home/daurnimator/src/zig/src/codegen.cpp:6340
#16 0x0000555555600cc9 in ir_render (g=0x555555a23af0, fn_entry=0x555555adda80) at /home/daurnimator/src/zig/src/codegen.cpp:6446
#17 0x0000555555606e6d in do_code_gen (g=0x555555a23af0) at /home/daurnimator/src/zig/src/codegen.cpp:7795
#18 0x00005555556112e5 in codegen_build_and_link (g=0x555555a23af0) at /home/daurnimator/src/zig/src/codegen.cpp:10341
#19 0x00005555555e443d in main (argc=3, argv=0x7fffffffc1e8) at /home/daurnimator/src/zig/src/main.cpp:1351

Seems to disappear if create doesn't return an error union, or if you preceed the testing.expectEqual line with e.g.

    const y = try MyIntWrapper.create();
@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 Dec 29, 2019
LemonBoy added a commit to LemonBoy/zig that referenced this issue Dec 30, 2019
@andrewrk andrewrk added this to the 0.6.0 milestone Dec 30, 2019
andrewrk pushed a commit that referenced this issue Dec 30, 2019
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

Successfully merging a pull request may close this issue.

2 participants