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

Array of anonymous nested tuples panic #19497

Open
charlesbjohnson opened this issue Mar 31, 2024 · 1 comment
Open

Array of anonymous nested tuples panic #19497

charlesbjohnson opened this issue Mar 31, 2024 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone

Comments

@charlesbjohnson
Copy link

charlesbjohnson commented Mar 31, 2024

Zig Version

0.12.0-dev.3498+aff71c613

Steps to Reproduce and Observed Behavior

Tangential, but I reduced the above 2 examples from an Advent of Code exercise that originally looked a bit like:
Reductions no longer reproduce, original example still does:

const std = @import("std");

pub fn main() !void {
    const allocator = std.heap.page_allocator;

    var tmp = std.ArrayList(struct { struct { u8, u8 }, struct { u8, u8 } }).init(allocator);
    defer tmp.deinit();

    try tmp.append(.{ .{ 0, 1 }, .{ 3, 4 } });

    repro(try tmp.toOwnedSlice());
}

fn repro(tmp: []struct { struct { u8, u8 }, struct { u8, u8 } }) void {
    std.debug.print("{d}\n", .{tmp.len});
}

https://godbolt.org/z/rzf786dEY

It works in 0.11.0, but broke when I upgraded to 0.12.0-dev. It appears that 0.11.0 is the only version where it works.

Output on 0.12.0-dev Debug build
PS C:\Users\Charlie\Projects\Self\x\zig> C:\Users\Charlie\zig\zig\build\stage3\bin\zig.exe run main.zig
thread 13296 panic: reached unreachable code
Analyzing main.zig: main.zig:main
      %5 = ret_type() node_offset:3:1 to :3:7
      %6 = dbg_stmt(2, 5)
      %7 = decl_val("std") token_offset:4:23 to :4:26
      %8 = dbg_stmt(2, 26)
      %9 = field_val(%7, "heap") node_offset:4:23 to :4:31
      %10 = dbg_stmt(2, 31)
      %11 = field_val(%9, "page_allocator") node_offset:4:23 to :4:46
      %12 = dbg_var_val(%11, "allocator")
      %13 = save_err_ret_index(%11)
      %14 = dbg_stmt(4, 5)
      %15 = alloc_inferred_mut() node_offset:6:5 to :6:93
      %16 = decl_ref("std") token_offset:6:15 to :6:18
      %17 = dbg_stmt(4, 28)
      %18 = field_call(.auto, %16, "ArrayList", [
        {
          %19 = extended(struct_decl(hash(10d37ff1d6daba374210a7c7df0a998e) tuple, anon, {}, auto, {}, {
            @"0": {%20, %21},
            @"1": {%22, %23},
          }) node_offset:6:29 to :6:76
          %24 = break_inline(%18, %19)
        },
      ]) node_offset:6:15 to :6:77
      %25 = ref(%18) token_offset:6:15 to :6:18
      %26 = dbg_stmt(4, 82)
      %27 = field_call(.auto, %25, "init", [
        {
          %28 = break_inline(%27, %11)
        },
      ]) node_offset:6:15 to :6:93
      %29 = store_to_inferred_ptr(%15, %27) node_offset:6:15 to :6:93
      %30 = resolve_inferred_alloc(%15) node_offset:6:5 to :6:93
      %31 = dbg_var_ptr(%15, "tmp")
      %35 = dbg_stmt(7, 19)
      %36 = field_call(.auto, %15, "append", [
        {
          %37 = validate_array_init_result_ty(%36, 2) node_offset:9:20 to :9:45
          %38 = array_init_elem_type(%36, 0)
          %39 = validate_array_init_result_ty(%38, 2) node_offset:9:23 to :9:32
          %40 = array_init_elem_type(%38, 0)
          %41 = array_init_elem_type(%38, 1)
          %42 = array_init(%38{@zero, @one}) node_offset:9:23 to :9:32
          %43 = array_init_elem_type(%36, 1)
          %44 = validate_array_init_result_ty(%43, 2) node_offset:9:34 to :9:43
          %45 = array_init_elem_type(%43, 0)
          %46 = int(3)
          %47 = array_init_elem_type(%43, 1)
          %48 = int(4)
          %49 = array_init(%43{%46, %48}) node_offset:9:34 to :9:43
          %50 = array_init(%36{%42, %49}) node_offset:9:20 to :9:45
          %51 = break_inline(%36, %50)
        },
      ]) node_offset:9:9 to :9:46
      %52 = try(%36, {
        %53 = err_union_code(%36) node_offset:9:5 to :9:46
        %54 = defer({
          %32 = dbg_stmt(5, 21)
          %33 = field_call(nodiscard .auto, %15, "deinit", []) node_offset:7:11 to :7:23
          %34 = break_inline(%0, @void_value)
        })
        %55 = dbg_stmt(7, 5)
        %56 = ret_node(%53) node_offset:9:5 to :9:46
      }) node_offset:9:5 to :9:46
      %57 = ensure_result_used(%52) node_offset:9:5 to :9:46
      %58 = dbg_stmt(9, 5)
      %59 = decl_val("repro") token_offset:11:5 to :11:10
      %60 = dbg_stmt(9, 10)
    > %61 = call(nodiscard .auto, %59, [
        {
          %62 = dbg_stmt(9, 31)
          %63 = field_call(.auto, %15, "toOwnedSlice", []) node_offset:11:15 to :11:33
          %64 = try(%63, {
            %65 = err_union_code(%63) node_offset:11:11 to :11:33
            %66 = defer({
              %32 = dbg_stmt(5, 21)
              %33 = field_call(nodiscard .auto, %15, "deinit", []) node_offset:7:11 to :7:23
              %34 = break_inline(%0, @void_value)
            })
            %67 = dbg_stmt(9, 11)
            %68 = ret_node(%65) node_offset:11:11 to :11:33
          }) node_offset:11:11 to :11:33
          %69 = break_inline(%61, %64)
        },
      ]) node_offset:11:5 to :11:34
      %70 = defer({
        %32 = dbg_stmt(5, 21)
        %33 = field_call(nodiscard .auto, %15, "deinit", []) node_offset:7:11 to :7:23
        %34 = break_inline(%0, @void_value)
      })
      %71 = restore_err_ret_index_unconditional(.none) node_offset:3:1 to :3:7
      %72 = ret_implicit(@void_value) token_offset:12:1 to :12:1
    For full context, use the command
      zig ast-check -t main.zig

  in C:\Users\Charlie\zig\zig\build\stage3\lib\zig\std\start.zig: start.zig:callMain
    > %1824 = is_non_err(%1823)
  in C:\Users\Charlie\zig\zig\build\stage3\lib\zig\std\start.zig: start.zig:callMain
    > %1826 = block({%1821..%1825})
  in C:\Users\Charlie\zig\zig\build\stage3\lib\zig\std\start.zig: start.zig:callMain
    > %1772 = switch_block(%1770,
        else => {%1915, %1918},
        %1773 => {%1774..%1778},
        %1779 => {%1780..%1788},
        by_val %1789 => {%1790..%1818},
        %1819 => {%1820..%1914})
  in C:\Users\Charlie\zig\zig\build\stage3\lib\zig\std\start.zig: start.zig:WinStartup
    > %1023 = call(.auto, %1021, [])
  in C:\Users\Charlie\zig\zig\build\stage3\lib\zig\std\start.zig: start.zig:WinStartup
    > %1020 = field_call(nodiscard .auto, %1018, "RtlExitUserProcess", [
        {%1021..%1024},
      ])

C:\Users\Charlie\zig\zig\src\type.zig:1043:35: 0x100c8b3 in abiAlignmentAdvanced (zig.exe.obj)
                        .eager => unreachable, // struct alignment not resolved
                                  ^
C:\Users\Charlie\zig\zig\src\type.zig:858:40: 0x100db19 in abiAlignment (zig.exe.obj)
        return (ty.abiAlignmentAdvanced(mod, .eager) catch unreachable).scalar;
                                       ^
C:\Users\Charlie\zig\zig\src\Module.zig:6228:45: 0x10a2889 in structFieldAlignment (zig.exe.obj)
                return field_ty.abiAlignment(mod);
                                            ^
C:\Users\Charlie\zig\zig\src\type.zig:3070:48: 0x1642129 in structFieldAlign (zig.exe.obj)
                return mod.structFieldAlignment(explicit_align, field_ty, struct_type.layout);
                                               ^
C:\Users\Charlie\zig\zig\src\Sema.zig:30068:41: 0x16bf5a3 in coerceInMemoryAllowed (zig.exe.obj)
            if (dest_ty.structFieldAlign(field_idx, mod) != src_ty.structFieldAlign(field_idx, mod)) break :tuple;
                                        ^
C:\Users\Charlie\zig\zig\src\Sema.zig:30323:49: 0x1bdefb9 in coerceInMemoryAllowedPtrs (zig.exe.obj)
    const child = try sema.coerceInMemoryAllowed(block, Type.fromInterned(dest_info.child), Type.fromInterned(src_info.child), !dest_info.flags.is_const, target, dest_src, src_src);
                                                ^
C:\Users\Charlie\zig\zig\src\Sema.zig:29905:50: 0x16bd253 in coerceInMemoryAllowed (zig.exe.obj)
        return try sema.coerceInMemoryAllowedPtrs(block, dest_ty, src_ty, dest_ty, src_ty, dest_is_mut, target, dest_src, src_src);
                                                 ^
C:\Users\Charlie\zig\zig\src\Sema.zig:28825:58: 0x12d01a4 in coerceExtra (zig.exe.obj)
    var in_memory_result = try sema.coerceInMemoryAllowed(block, dest_ty, inst_ty, false, target, dest_ty_src, inst_src);
                                                         ^
C:\Users\Charlie\zig\zig\src\Sema.zig:7350:44: 0x215d497 in analyzeArg (zig.exe.obj)
            else => return sema.coerceExtra(
                                           ^
C:\Users\Charlie\zig\zig\src\Sema.zig:7894:49: 0x1bebec9 in analyzeCall (zig.exe.obj)
            arg_out.* = try args_info.analyzeArg(sema, block, arg_idx, param_ty, func_ty_info, func);
                                                ^
C:\Users\Charlie\zig\zig\src\Sema.zig:7043:43: 0x1a88853 in zirCall__anon_92561 (zig.exe.obj)
    const call_inst = try sema.analyzeCall(block, func, func_ty, callee_src, call_src, modifier, ensure_result_used, args_info, call_dbg_node, .call);
                                          ^
C:\Users\Charlie\zig\zig\src\Sema.zig:1015:62: 0x159c62d in analyzeBodyInner (zig.exe.obj)
            .call                         => try sema.zirCall(block, inst, .direct),
                                                             ^
C:\Users\Charlie\zig\zig\src\Sema.zig:893:26: 0x159b093 in analyzeFnBody (zig.exe.obj)
    sema.analyzeBodyInner(block, body) catch |err| switch (err) {
                         ^
C:\Users\Charlie\zig\zig\src\Module.zig:4609:23: 0x12894d5 in analyzeFnBody (zig.exe.obj)
    sema.analyzeFnBody(&inner_block, fn_info.body) catch |err| switch (err) {
                      ^
C:\Users\Charlie\zig\zig\src\Module.zig:3144:32: 0xffa78a in ensureFuncBodyAnalyzed (zig.exe.obj)
    var air = zcu.analyzeFnBody(func_index, sema_arena) catch |err| switch (err) {
                               ^
C:\Users\Charlie\zig\zig\src\Sema.zig:32490:31: 0x1bf8a4a in ensureFuncBodyAnalyzed (zig.exe.obj)
    mod.ensureFuncBodyAnalyzed(func) catch |err| {
                              ^
C:\Users\Charlie\zig\zig\src\Sema.zig:36481:40: 0x16b41e0 in resolveInferredErrorSet (zig.exe.obj)
        try sema.ensureFuncBodyAnalyzed(func_index);
                                       ^
C:\Users\Charlie\zig\zig\src\Sema.zig:32850:69: 0x1b40b73 in analyzeIsNonErrComptimeOnly (zig.exe.obj)
                const resolved_ty = try sema.resolveInferredErrorSet(block, src, set_ty);
                                                                    ^
C:\Users\Charlie\zig\zig\src\Sema.zig:32879:56: 0x1f45f8a in analyzeIsNonErr (zig.exe.obj)
    const result = try sema.analyzeIsNonErrComptimeOnly(block, src, operand);
                                                       ^
C:\Users\Charlie\zig\zig\src\Sema.zig:19076:32: 0x1a9716a in zirIsNonErr (zig.exe.obj)
    return sema.analyzeIsNonErr(block, src, operand);
                               ^
C:\Users\Charlie\zig\zig\src\Sema.zig:1057:66: 0x159e2c7 in analyzeBodyInner (zig.exe.obj)
            .is_non_err                   => try sema.zirIsNonErr(block, inst),
                                                                 ^
C:\Users\Charlie\zig\zig\src\Sema.zig:6099:34: 0x1f6f538 in resolveBlockBody (zig.exe.obj)
        if (sema.analyzeBodyInner(child_block, body)) |_| {
                                 ^
C:\Users\Charlie\zig\zig\src\Sema.zig:6076:33: 0x1b43717 in zirBlock (zig.exe.obj)
    return sema.resolveBlockBody(parent_block, src, &child_block, body, inst, &label.merges);
                                ^
C:\Users\Charlie\zig\zig\src\Sema.zig:1560:49: 0x15abc97 in analyzeBodyInner (zig.exe.obj)
                    break :blk try sema.zirBlock(block, inst, tags[@intFromEnum(inst)] == .block_comptime);
                                                ^
C:\Users\Charlie\zig\zig\src\Sema.zig:6099:34: 0x1f6f538 in resolveBlockBody (zig.exe.obj)
        if (sema.analyzeBodyInner(child_block, body)) |_| {
                                 ^
C:\Users\Charlie\zig\zig\src\Sema.zig:10910:45: 0x1f65fe9 in resolveProngComptime (zig.exe.obj)
                return sema.resolveBlockBody(spa.parent_block, src, child_block, prong_body, spa.switch_block_inst, merges);
                                            ^
C:\Users\Charlie\zig\zig\src\Sema.zig:13060:48: 0x1f647ed in resolveSwitchComptime (zig.exe.obj)
                return spa.resolveProngComptime(
                                               ^
C:\Users\Charlie\zig\zig\src\Sema.zig:12299:37: 0x1aa6cd6 in zirSwitchBlock (zig.exe.obj)
        return resolveSwitchComptime(
                                    ^
C:\Users\Charlie\zig\zig\src\Sema.zig:1080:69: 0x159f251 in analyzeBodyInner (zig.exe.obj)
            .switch_block                 => try sema.zirSwitchBlock(block, inst, false),
                                                                    ^
C:\Users\Charlie\zig\zig\src\Sema.zig:893:26: 0x159b093 in analyzeFnBody (zig.exe.obj)
    sema.analyzeBodyInner(block, body) catch |err| switch (err) {
                         ^
C:\Users\Charlie\zig\zig\src\Sema.zig:7839:35: 0x1beb0a9 in analyzeCall (zig.exe.obj)
                sema.analyzeFnBody(&child_block, fn_info.body) catch |err| switch (err) {
                                  ^
C:\Users\Charlie\zig\zig\src\Sema.zig:7043:43: 0x1a88853 in zirCall__anon_92561 (zig.exe.obj)
    const call_inst = try sema.analyzeCall(block, func, func_ty, callee_src, call_src, modifier, ensure_result_used, args_info, call_dbg_node, .call);
                                          ^
C:\Users\Charlie\zig\zig\src\Sema.zig:1015:62: 0x159c62d in analyzeBodyInner (zig.exe.obj)
            .call                         => try sema.zirCall(block, inst, .direct),
                                                             ^
C:\Users\Charlie\zig\zig\src\Sema.zig:911:30: 0x12caf82 in analyzeInlineBody (zig.exe.obj)
    if (sema.analyzeBodyInner(block, body)) |_| {
                             ^
C:\Users\Charlie\zig\zig\src\Sema.zig:937:39: 0x1021fb0 in resolveInlineBody (zig.exe.obj)
    return (try sema.analyzeInlineBody(block, body, break_target)) orelse .unreachable_value;
                                      ^
C:\Users\Charlie\zig\zig\src\Sema.zig:7332:65: 0x215cebf in analyzeArg (zig.exe.obj)
                const uncoerced_arg = try sema.resolveInlineBody(block, arg_body, zir_call.call_inst);
                                                                ^
C:\Users\Charlie\zig\zig\src\Sema.zig:7894:49: 0x1bebec9 in analyzeCall (zig.exe.obj)
            arg_out.* = try args_info.analyzeArg(sema, block, arg_idx, param_ty, func_ty_info, func);
                                                ^
C:\Users\Charlie\zig\zig\src\Sema.zig:7043:43: 0x1a89b16 in zirCall__anon_92562 (zig.exe.obj)
    const call_inst = try sema.analyzeCall(block, func, func_ty, callee_src, call_src, modifier, ensure_result_used, args_info, call_dbg_node, .call);
                                          ^
C:\Users\Charlie\zig\zig\src\Sema.zig:1016:62: 0x159c6d8 in analyzeBodyInner (zig.exe.obj)
            .field_call                   => try sema.zirCall(block, inst, .field),
                                                             ^
C:\Users\Charlie\zig\zig\src\Sema.zig:893:26: 0x159b093 in analyzeFnBody (zig.exe.obj)
    sema.analyzeBodyInner(block, body) catch |err| switch (err) {
                         ^
C:\Users\Charlie\zig\zig\src\Module.zig:4609:23: 0x12894d5 in analyzeFnBody (zig.exe.obj)
    sema.analyzeFnBody(&inner_block, fn_info.body) catch |err| switch (err) {
                      ^
C:\Users\Charlie\zig\zig\src\Module.zig:3144:32: 0xffa78a in ensureFuncBodyAnalyzed (zig.exe.obj)
    var air = zcu.analyzeFnBody(func_index, sema_arena) catch |err| switch (err) {
                               ^
C:\Users\Charlie\zig\zig\src\Compilation.zig:3419:42: 0xff862b in processOneJob (zig.exe.obj)
            module.ensureFuncBodyAnalyzed(func) catch |err| switch (err) {
                                         ^
C:\Users\Charlie\zig\zig\src\Compilation.zig:3359:30: 0xe251d1 in performAllTheWork (zig.exe.obj)
            try processOneJob(comp, work_item, main_progress_node);
                             ^
C:\Users\Charlie\zig\zig\src\Compilation.zig:2132:31: 0xe20589 in update (zig.exe.obj)
    try comp.performAllTheWork(main_progress_node);
                              ^
C:\Users\Charlie\zig\zig\src\main.zig:4507:24: 0xe51ca2 in updateModule (zig.exe.obj)
        try comp.update(main_progress_node);
                       ^
C:\Users\Charlie\zig\zig\src\main.zig:3414:17: 0xebcbcd in buildOutputType (zig.exe.obj)
    updateModule(comp, color) catch |err| switch (err) {
                ^
C:\Users\Charlie\zig\zig\src\main.zig:268:31: 0xcf416b in mainArgs (zig.exe.obj)
        return buildOutputType(gpa, arena, args, .run);
                              ^
C:\Users\Charlie\zig\zig\src\main.zig:206:20: 0xcf151e in main (zig.exe.obj)
    return mainArgs(gpa, arena, args);
                   ^
C:\Users\Charlie\zig\zig\lib\std\start.zig:484:5: 0xcf124a in main (zig.exe.obj)
    return callMainWithArgs(@as(usize, @intCast(c_argc)), @as([*][*:0]u8, @ptrCast(c_argv)), envp);
    ^
C:\Users\Charlie\zig\zig\lib\libc\mingw\crt\crtexe.c:267:0: 0x34aa715 in __tmainCRTStartup (crt2.obj)
    mainret = _tmain (argc, argv, envp);

C:\Users\Charlie\zig\zig\lib\libc\mingw\crt\crtexe.c:188:0: 0x34aa76b in mainCRTStartup (crt2.obj)
  ret = __tmainCRTStartup ();

???:?:?: 0x7ffb2a477343 in ??? (KERNEL32.DLL)
???:?:?: 0x7ffb2c0626b0 in ??? (ntdll.dll)

Expected Behavior

  • Compiler not to panic
  • Friendly error message if code is invalid (idk if it is, I'm new to Zig 🤷‍♂️)
@charlesbjohnson charlesbjohnson added the bug Observed behavior contradicts documented or intended behavior label Mar 31, 2024
@Vexu Vexu added the frontend Tokenization, parsing, AstGen, Sema, and Liveness. label Mar 31, 2024
@Vexu Vexu added this to the 0.13.0 milestone Mar 31, 2024
@wrongnull
Copy link
Contributor

wrongnull commented Apr 1, 2024

here's debug stack trace
thread 1276 panic: reached unreachable code
Analyzing repr.zig: repr.zig:main
      %5 = ret_type() node_offset:3:1 to :3:7
      %6 = dbg_stmt(2, 5)
      %7 = decl_val("std") token_offset:4:23 to :4:26
      %8 = dbg_stmt(2, 26)
      %9 = field_val(%7, "heap") node_offset:4:23 to :4:31
      %10 = dbg_stmt(2, 31)
      %11 = field_val(%9, "page_allocator") node_offset:4:23 to :4:46
      %12 = dbg_var_val(%11, "allocator")
      %13 = save_err_ret_index(%11)
      %14 = dbg_stmt(4, 5)
      %15 = alloc_inferred_mut() node_offset:6:5 to :6:93
      %16 = decl_ref("std") token_offset:6:15 to :6:18
      %17 = dbg_stmt(4, 28)
      %18 = field_call(.auto, %16, "ArrayList", [
        {
          %19 = extended(struct_decl(hash(10d37ff1d6daba374210a7c7df0a998e) tuple, anon, {}, auto, {}, {
            @"0": {%20, %21},
            @"1": {%22, %23},
          }) node_offset:6:29 to :6:76
          %24 = break_inline(%18, %19)
        },
      ]) node_offset:6:15 to :6:77
      %25 = ref(%18) token_offset:6:15 to :6:18
      %26 = dbg_stmt(4, 82)
      %27 = field_call(.auto, %25, "init", [
        {
          %28 = break_inline(%27, %11)
        },
      ]) node_offset:6:15 to :6:93
      %29 = store_to_inferred_ptr(%15, %27) node_offset:6:15 to :6:93
      %30 = resolve_inferred_alloc(%15) node_offset:6:5 to :6:93
      %31 = dbg_var_ptr(%15, "tmp")
      %35 = dbg_stmt(7, 19)
      %36 = field_call(.auto, %15, "append", [
        {
          %37 = validate_array_init_result_ty(%36, 2) node_offset:9:20 to :9:45
          %38 = array_init_elem_type(%36, 0)
          %39 = validate_array_init_result_ty(%38, 2) node_offset:9:23 to :9:32
          %40 = array_init_elem_type(%38, 0)
          %41 = array_init_elem_type(%38, 1)
          %42 = array_init(%38{@zero, @one}) node_offset:9:23 to :9:32
          %43 = array_init_elem_type(%36, 1)
          %44 = validate_array_init_result_ty(%43, 2) node_offset:9:34 to :9:43
          %45 = array_init_elem_type(%43, 0)
          %46 = int(3)
          %47 = array_init_elem_type(%43, 1)
          %48 = int(4)
          %49 = array_init(%43{%46, %48}) node_offset:9:34 to :9:43
          %50 = array_init(%36{%42, %49}) node_offset:9:20 to :9:45
          %51 = break_inline(%36, %50)
        },
      ]) node_offset:9:9 to :9:46
      %52 = try(%36, {
        %53 = err_union_code(%36) node_offset:9:5 to :9:46
        %54 = defer({
          %32 = dbg_stmt(5, 21)
          %33 = field_call(nodiscard .auto, %15, "deinit", []) node_offset:7:11 to :7:23
          %34 = break_inline(%0, @void_value)
        })
        %55 = dbg_stmt(7, 5)
        %56 = ret_node(%53) node_offset:9:5 to :9:46
      }) node_offset:9:5 to :9:46
      %57 = ensure_result_used(%52) node_offset:9:5 to :9:46
      %58 = dbg_stmt(9, 5)
      %59 = decl_val("repro") token_offset:11:5 to :11:10
      %60 = dbg_stmt(9, 10)
    > %61 = call(nodiscard .auto, %59, [
        {
          %62 = dbg_stmt(9, 31)
          %63 = field_call(.auto, %15, "toOwnedSlice", []) node_offset:11:15 to :11:33
          %64 = try(%63, {
            %65 = err_union_code(%63) node_offset:11:11 to :11:33
            %66 = defer({
              %32 = dbg_stmt(5, 21)
              %33 = field_call(nodiscard .auto, %15, "deinit", []) node_offset:7:11 to :7:23
              %34 = break_inline(%0, @void_value)
            })
            %67 = dbg_stmt(9, 11)
            %68 = ret_node(%65) node_offset:11:11 to :11:33
          }) node_offset:11:11 to :11:33
          %69 = break_inline(%61, %64)
        },
      ]) node_offset:11:5 to :11:34
      %70 = defer({
        %32 = dbg_stmt(5, 21)
        %33 = field_call(nodiscard .auto, %15, "deinit", []) node_offset:7:11 to :7:23
        %34 = break_inline(%0, @void_value)
      })
      %71 = restore_err_ret_index_unconditional(.none) node_offset:3:1 to :3:7
      %72 = ret_implicit(@void_value) token_offset:12:1 to :12:1
    For full context, use the command
      zig ast-check -t repr.zig

  in zig-out/lib/zig/std/start.zig: start.zig:callMain
    > %1824 = is_non_err(%1823)
  in zig-out/lib/zig/std/start.zig: start.zig:callMain
    > %1826 = block({%1821..%1825})
  in zig-out/lib/zig/std/start.zig: start.zig:callMain
    > %1772 = switch_block(%1770,
        else => {%1915, %1918},
        %1773 => {%1774..%1778},
        %1779 => {%1780..%1788},
        by_val %1789 => {%1790..%1818},
        %1819 => {%1820..%1914})
  in zig-out/lib/zig/std/start.zig: start.zig:callMainWithArgs
    > %1577 = call(.auto, %1575, [])
  in zig-out/lib/zig/std/start.zig: start.zig:posixCallMainAndExit
    > %1414 = call(.auto, %1412, [
        {%1415},
        {%1416},
        {%1417},
      ])
  in zig-out/lib/zig/std/start.zig: start.zig:posixCallMainAndExit
    > %1411 = field_call(nodiscard .auto, %1409, "exit", [
        {%1412..%1418},
      ])

/home/wrongnull/projects/zig/src/type.zig:1046:35: 0x1a7a2af in abiAlignmentAdvanced (zig)
                        .eager => unreachable, // struct alignment not resolved
                                  ^
/home/wrongnull/projects/zig/src/type.zig:858:40: 0x1a7b18f in abiAlignment (zig)
        return (ty.abiAlignmentAdvanced(mod, .eager) catch unreachable).scalar;
                                       ^
/home/wrongnull/projects/zig/src/Module.zig:6228:45: 0x1b079ba in structFieldAlignment (zig)
                return field_ty.abiAlignment(mod);
                                            ^
/home/wrongnull/projects/zig/src/type.zig:3068:48: 0x1fad23d in structFieldAlign (zig)
                return mod.structFieldAlignment(explicit_align, field_ty, struct_type.layout);
                                               ^
/home/wrongnull/projects/zig/src/Sema.zig:30128:41: 0x20207e5 in coerceInMemoryAllowed (zig)
            if (dest_ty.structFieldAlign(field_idx, mod) != src_ty.structFieldAlign(field_idx, mod)) break :tuple;
                                        ^
/home/wrongnull/projects/zig/src/Sema.zig:30383:49: 0x24a2160 in coerceInMemoryAllowedPtrs (zig)
    const child = try sema.coerceInMemoryAllowed(block, Type.fromInterned(dest_info.child), Type.fromInterned(src_info.child), !dest_info.flags.is_const, target, dest_src, src_src);
                                                ^
/home/wrongnull/projects/zig/src/Sema.zig:29965:50: 0x201e8c5 in coerceInMemoryAllowed (zig)
        return try sema.coerceInMemoryAllowedPtrs(block, dest_ty, src_ty, dest_ty, src_ty, dest_is_mut, target, dest_src, src_src);
                                                 ^
/home/wrongnull/projects/zig/src/Sema.zig:28885:58: 0x1cdfa61 in coerceExtra (zig)
    var in_memory_result = try sema.coerceInMemoryAllowed(block, dest_ty, inst_ty, false, target, dest_ty_src, inst_src);
                                                         ^
/home/wrongnull/projects/zig/src/Sema.zig:7350:44: 0x2980fec in analyzeArg (zig)
            else => return sema.coerceExtra(
                                           ^
/home/wrongnull/projects/zig/src/Sema.zig:7894:49: 0x24adf94 in analyzeCall (zig)
            arg_out.* = try args_info.analyzeArg(sema, block, arg_idx, param_ty, func_ty_info, func);
                                                ^
/home/wrongnull/projects/zig/src/Sema.zig:7043:43: 0x236e214 in zirCall__anon_88222 (zig)
    const call_inst = try sema.analyzeCall(block, func, func_ty, callee_src, call_src, modifier, ensure_result_used, args_info, call_dbg_node, .call);
                                          ^
/home/wrongnull/projects/zig/src/Sema.zig:1015:62: 0x1f1abff in analyzeBodyInner (zig)
            .call                         => try sema.zirCall(block, inst, .direct),
                                                             ^
/home/wrongnull/projects/zig/src/Sema.zig:893:26: 0x1f19ac4 in analyzeFnBody (zig)
    sema.analyzeBodyInner(block, body) catch |err| switch (err) {
                         ^
/home/wrongnull/projects/zig/src/Module.zig:4609:23: 0x1caaa10 in analyzeFnBody (zig)
    sema.analyzeFnBody(&inner_block, fn_info.body) catch |err| switch (err) {
                      ^
/home/wrongnull/projects/zig/src/Module.zig:3144:32: 0x1a6e239 in ensureFuncBodyAnalyzed (zig)
    var air = zcu.analyzeFnBody(func_index, sema_arena) catch |err| switch (err) {
                               ^
/home/wrongnull/projects/zig/src/Sema.zig:32550:31: 0x24b9620 in ensureFuncBodyAnalyzed (zig)
    mod.ensureFuncBodyAnalyzed(func) catch |err| {
                              ^
/home/wrongnull/projects/zig/src/Sema.zig:36544:40: 0x201666f in resolveInferredErrorSet (zig)
        try sema.ensureFuncBodyAnalyzed(func_index);
                                       ^
/home/wrongnull/projects/zig/src/Sema.zig:32910:69: 0x24145bf in analyzeIsNonErrComptimeOnly (zig)
                const resolved_ty = try sema.resolveInferredErrorSet(block, src, set_ty);
                                                                    ^
/home/wrongnull/projects/zig/src/Sema.zig:32939:56: 0x27a169c in analyzeIsNonErr (zig)
    const result = try sema.analyzeIsNonErrComptimeOnly(block, src, operand);
                                                       ^
/home/wrongnull/projects/zig/src/Sema.zig:19082:32: 0x237b9a9 in zirIsNonErr (zig)
    return sema.analyzeIsNonErr(block, src, operand);
                               ^
/home/wrongnull/projects/zig/src/Sema.zig:1057:66: 0x1f1c2a3 in analyzeBodyInner (zig)
            .is_non_err                   => try sema.zirIsNonErr(block, inst),
                                                                 ^
/home/wrongnull/projects/zig/src/Sema.zig:6099:34: 0x27c5f1f in resolveBlockBody (zig)
        if (sema.analyzeBodyInner(child_block, body)) |_| {
                                 ^
/home/wrongnull/projects/zig/src/Sema.zig:6076:33: 0x2416d67 in zirBlock (zig)
    return sema.resolveBlockBody(parent_block, src, &child_block, body, inst, &label.merges);
                                ^
/home/wrongnull/projects/zig/src/Sema.zig:1560:49: 0x1f27708 in analyzeBodyInner (zig)
                    break :blk try sema.zirBlock(block, inst, tags[@intFromEnum(inst)] == .block_comptime);
                                                ^
/home/wrongnull/projects/zig/src/Sema.zig:6099:34: 0x27c5f1f in resolveBlockBody (zig)
        if (sema.analyzeBodyInner(child_block, body)) |_| {
                                 ^
/home/wrongnull/projects/zig/src/Sema.zig:10910:45: 0x27bd45b in resolveProngComptime (zig)
                return sema.resolveBlockBody(spa.parent_block, src, child_block, prong_body, spa.switch_block_inst, merges);
                                            ^
/home/wrongnull/projects/zig/src/Sema.zig:13060:48: 0x27bbdba in resolveSwitchComptime (zig)
                return spa.resolveProngComptime(
                                               ^
/home/wrongnull/projects/zig/src/Sema.zig:12299:37: 0x238a5a9 in zirSwitchBlock (zig)
        return resolveSwitchComptime(
                                    ^
/home/wrongnull/projects/zig/src/Sema.zig:1080:69: 0x1f1ced5 in analyzeBodyInner (zig)
            .switch_block                 => try sema.zirSwitchBlock(block, inst, false),
                                                                    ^
/home/wrongnull/projects/zig/src/Sema.zig:893:26: 0x1f19ac4 in analyzeFnBody (zig)
    sema.analyzeBodyInner(block, body) catch |err| switch (err) {
                         ^
/home/wrongnull/projects/zig/src/Sema.zig:7839:35: 0x24ad30f in analyzeCall (zig)
                sema.analyzeFnBody(&child_block, fn_info.body) catch |err| switch (err) {
                                  ^
/home/wrongnull/projects/zig/src/Sema.zig:7043:43: 0x236e214 in zirCall__anon_88222 (zig)
    const call_inst = try sema.analyzeCall(block, func, func_ty, callee_src, call_src, modifier, ensure_result_used, args_info, call_dbg_node, .call);
                                          ^
/home/wrongnull/projects/zig/src/Sema.zig:1015:62: 0x1f1abff in analyzeBodyInner (zig)
            .call                         => try sema.zirCall(block, inst, .direct),
                                                             ^
/home/wrongnull/projects/zig/src/Sema.zig:893:26: 0x1f19ac4 in analyzeFnBody (zig)
    sema.analyzeBodyInner(block, body) catch |err| switch (err) {
                         ^
/home/wrongnull/projects/zig/src/Sema.zig:7839:35: 0x24ad30f in analyzeCall (zig)
                sema.analyzeFnBody(&child_block, fn_info.body) catch |err| switch (err) {
                                  ^
/home/wrongnull/projects/zig/src/Sema.zig:7043:43: 0x236e214 in zirCall__anon_88222 (zig)
    const call_inst = try sema.analyzeCall(block, func, func_ty, callee_src, call_src, modifier, ensure_result_used, args_info, call_dbg_node, .call);
                                          ^
/home/wrongnull/projects/zig/src/Sema.zig:1015:62: 0x1f1abff in analyzeBodyInner (zig)
            .call                         => try sema.zirCall(block, inst, .direct),
                                                             ^
/home/wrongnull/projects/zig/src/Sema.zig:911:30: 0x1cdaf94 in analyzeInlineBody (zig)
    if (sema.analyzeBodyInner(block, body)) |_| {
                             ^
/home/wrongnull/projects/zig/src/Sema.zig:937:39: 0x1a8cd51 in resolveInlineBody (zig)
    return (try sema.analyzeInlineBody(block, body, break_target)) orelse .unreachable_value;
                                      ^
/home/wrongnull/projects/zig/src/Sema.zig:7332:65: 0x2980ab1 in analyzeArg (zig)
                const uncoerced_arg = try sema.resolveInlineBody(block, arg_body, zir_call.call_inst);
                                                                ^
/home/wrongnull/projects/zig/src/Sema.zig:7894:49: 0x24adf94 in analyzeCall (zig)
            arg_out.* = try args_info.analyzeArg(sema, block, arg_idx, param_ty, func_ty_info, func);
                                                ^
/home/wrongnull/projects/zig/src/Sema.zig:7043:43: 0x236f338 in zirCall__anon_88223 (zig)
    const call_inst = try sema.analyzeCall(block, func, func_ty, callee_src, call_src, modifier, ensure_result_used, args_info, call_dbg_node, .call);
                                          ^
/home/wrongnull/projects/zig/src/Sema.zig:1016:62: 0x1f1ac86 in analyzeBodyInner (zig)
            .field_call                   => try sema.zirCall(block, inst, .field),
                                                             ^
/home/wrongnull/projects/zig/src/Sema.zig:893:26: 0x1f19ac4 in analyzeFnBody (zig)
    sema.analyzeBodyInner(block, body) catch |err| switch (err) {
                         ^
/home/wrongnull/projects/zig/src/Module.zig:4609:23: 0x1caaa10 in analyzeFnBody (zig)
    sema.analyzeFnBody(&inner_block, fn_info.body) catch |err| switch (err) {
                      ^
/home/wrongnull/projects/zig/src/Module.zig:3144:32: 0x1a6e239 in ensureFuncBodyAnalyzed (zig)
    var air = zcu.analyzeFnBody(func_index, sema_arena) catch |err| switch (err) {
                               ^
/home/wrongnull/projects/zig/src/Compilation.zig:3419:42: 0x1a6c138 in processOneJob (zig)
            module.ensureFuncBodyAnalyzed(func) catch |err| switch (err) {
                                         ^
/home/wrongnull/projects/zig/src/Compilation.zig:3359:30: 0x190d237 in performAllTheWork (zig)
            try processOneJob(comp, work_item, main_progress_node);
                             ^
/home/wrongnull/projects/zig/src/Compilation.zig:2132:31: 0x1908efe in update (zig)
    try comp.performAllTheWork(main_progress_node);
                              ^
/home/wrongnull/projects/zig/src/main.zig:4503:24: 0x1936b2e in updateModule (zig)
        try comp.update(main_progress_node);
                       ^
/home/wrongnull/projects/zig/src/main.zig:3414:17: 0x1967aa4 in buildOutputType (zig)
    updateModule(comp, color) catch |err| switch (err) {
                ^
/home/wrongnull/projects/zig/src/main.zig:260:31: 0x18016ca in mainArgs (zig)
        return buildOutputType(gpa, arena, args, .{ .build = .Exe });
                              ^
/home/wrongnull/projects/zig/src/main.zig:206:20: 0x17fd87a in main (zig)
    return mainArgs(gpa, arena, args);
                   ^
/home/wrongnull/projects/zig/build/stage3/lib/zig/std/start.zig:511:37: 0x17fcf75 in posixCallMainAndExit (zig)
            const result = root.main() catch |err| {
                                    ^
/home/wrongnull/projects/zig/build/stage3/lib/zig/std/start.zig:253:5: 0x17fca91 in _start (zig)
    asm volatile (switch (native_arch) {
    ^
???:?:?: 0x2 in ??? (???)
Unwind information for `???:0x2` was not available, trace may be incomplete

Aborted

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 frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Projects
None yet
Development

No branches or pull requests

3 participants