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

ICE: generic poison when using anytype in function proto argument #21099

Open
Rexicon226 opened this issue Aug 16, 2024 · 1 comment
Open

ICE: generic poison when using anytype in function proto argument #21099

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

Comments

@Rexicon226
Copy link
Contributor

const std = @import("std");

pub fn foo(comptime _: fn (anytype, anytype, anytype) void) void {}

test {
    const Bar = struct {
        pub fn inner(_: anytype, _: void, _: void) void {}
    };
    foo(Bar.inner);
}
Stack Trace
thread 600643 panic: attempt to unwrap error: GenericPoison
Analyzing empty.zig
      %97 = dbg_stmt(2, 5)
      %98 = decl_val("Interval") 
      %99 = dbg_stmt(2, 32)
      %100 = call(.auto, %98, [
        {
          %101 = break_inline(%100, @u8_type)
        },
      ]) 
      %102 = dbg_var_val(%100, "IntervalU8")
      %103 = save_err_ret_index(%100)
      %104 = dbg_stmt(3, 5)
      %105 = int(4)
      %106 = block_comptime({
        %107 = break(%106, %100)
      }) 
      %108 = array_type(%105, %106) 
      %109 = validate_struct_init_result_ty(%106) 
      %110 = struct_init_field_type(%106, start) 
      %111 = struct_init_field_type(%106, stop) 
      %112 = int(100)
      %113 = struct_init([%110, @zero], [%111, %112]) 
      %114 = validate_struct_init_result_ty(%106) 
      %115 = struct_init_field_type(%106, start) 
      %116 = int(150)
      %117 = struct_init_field_type(%106, stop) 
      %118 = int(152)
      %119 = struct_init([%115, %116], [%117, %118]) 
      %120 = validate_struct_init_result_ty(%106) 
      %121 = struct_init_field_type(%106, start) 
      %122 = int(152)
      %123 = struct_init_field_type(%106, stop) 
      %124 = int(153)
      %125 = struct_init([%121, %122], [%123, %124]) 
      %126 = validate_struct_init_result_ty(%106) 
      %127 = struct_init_field_type(%106, start) 
      %128 = int(200)
      %129 = struct_init_field_type(%106, stop) 
      %130 = int(240)
      %131 = struct_init([%127, %128], [%129, %130]) 
      %132 = array_init(%108{%113, %119, %125, %131}) 
      %155 = ref(%132) 
      %133 = dbg_var_val(%132, "IVS_INITIAL_VALUES")
      %134 = dbg_stmt(9, 5)
      %135 = alloc_inferred_mut() 
      %136 = decl_ref("std") 
      %137 = dbg_stmt(9, 28)
      %138 = field_call(.auto, %136, "ArrayList", [
        {
          %139 = break_inline(%138, %100)
        },
      ]) 
      %140 = ref(%138) 
      %141 = dbg_stmt(9, 45)
      %142 = field_call(.auto, %140, "init", [
        {
          %143 = decl_val("std") 
          %144 = dbg_stmt(9, 49)
          %145 = field_val(%143, "testing") 
          %146 = dbg_stmt(9, 57)
          %147 = field_val(%145, "allocator") 
          %148 = break_inline(%142, %147)
        },
      ]) 
      %149 = store_to_inferred_ptr(%135, %142) 
      %150 = resolve_inferred_alloc(%135) 
      %151 = dbg_var_ptr(%135, "ivs")
      %152 = dbg_stmt(10, 24)
      %153 = field_call(.auto, %135, "appendSlice", [
        {
          %154 = validate_ref_ty(%153) 
          %156 = break_inline(%153, %155)
        },
      ]) 
      %157 = try(%153, {
        %158 = err_union_code(%153) 
        %159 = dbg_stmt(10, 5)
        %160 = ret_node(%158) 
      }) 
      %161 = ensure_result_used(%157) 
      %165 = dbg_stmt(13, 5)
      %166 = extended(struct_decl(hash(2f03488edf70f049e11a99171a65c4a6) dbg_var, { %100 }, auto, {
        %167 = declaration(pub 'inner' line(38) hash(40d26f54702f662ee3ec2cf8a4e52336) value={%168..%192}) 
      }, {}, {}) 
      %193 = dbg_var_val(%166, "Orderer")
      %194 = dbg_stmt(18, 5)
      %195 = decl_val("compilerBreaksWhenThisIsCalled") 
      %196 = dbg_stmt(18, 39)
    > %197 = call(.auto, %195, [
        {
          %198 = break_inline(%197, %100)
        },
        {
          %199 = validate_struct_init_result_ty(%197) 
          %200 = struct_init_field_type(%197, start) 
          %201 = int(250)
          %202 = struct_init_field_type(%197, stop) 
          %203 = int(255)
          %204 = struct_init([%200, %201], [%202, %203]) 
          %205 = break_inline(%197, %204)
        },
        {
          %206 = load(%135) 
          %207 = dbg_stmt(18, 85)
          %208 = field_val(%206, "items") 
          %209 = break_inline(%197, %208)
        },
        {
          %210 = struct_init_empty_result(%197) 
          %211 = break_inline(%197, %210)
        },
        {
          %212 = dbg_stmt(18, 105)
          %213 = field_val(%166, "inner") 
          %214 = break_inline(%197, %213)
        },
      ]) 
      %215 = ensure_result_non_error(%197) 
      %216 = defer({
        %162 = dbg_stmt(11, 21)
        %163 = field_call(nodiscard .auto, %135, "deinit", []) 
        %164 = break_inline(%0, @void_value)
      })
      %217 = restore_err_ret_index_unconditional(.none) 
      %218 = ret_implicit(@void_value) 
    For full context, use the command
      zig ast-check -t empty.zig


/Users/david/Code/zig/src/InternPool.zig:11489:33: 0x111c1c76f in zigTypeTagOrPoison (zig)
        .generic_poison_type => return error.GenericPoison,
                                ^
/Users/david/Code/zig/src/Type.zig:31:5: 0x11195607f in zigTypeTagOrPoison (zig)
    return mod.intern_pool.zigTypeTagOrPoison(ty.toIntern());
    ^
/Users/david/Code/zig/src/Type.zig:27:45: 0x111714acf in zigTypeTag (zig)
    return ty.zigTypeTagOrPoison(mod) catch unreachable;
                                            ^
/Users/david/Code/zig/src/Sema.zig:30364:38: 0x111e3fedf in coerceInMemoryAllowed (zig)
    const src_tag = src_ty.zigTypeTag(mod);
                                     ^
/Users/david/Code/zig/src/Sema.zig:30784:61: 0x1122dc5df in coerceInMemoryAllowedFns (zig)
                const param = try sema.coerceInMemoryAllowed(block, src_param_ty, dest_param_ty, false, target, dest_src, src_src, null);
                                                            ^
/Users/david/Code/zig/src/Sema.zig:30425:49: 0x111e4098f in coerceInMemoryAllowed (zig)
        return try sema.coerceInMemoryAllowedFns(block, dest_ty, src_ty, target, dest_src, src_src);
                                                ^
/Users/david/Code/zig/src/Sema.zig:29288:58: 0x111b321df in coerceExtra (zig)
    var in_memory_result = try sema.coerceInMemoryAllowed(block, dest_ty, inst_ty, false, target, dest_ty_src, inst_src, maybe_inst_val);
                                                         ^
/Users/david/Code/zig/src/Sema.zig:7386:44: 0x112743323 in analyzeArg (zig)
            else => return sema.coerceExtra(
                                           ^
/Users/david/Code/zig/src/Sema.zig:8056:56: 0x1127417a7 in analyzeInlineCallArg (zig)
            const casted_arg = try args_info.analyzeArg(ics.caller(), arg_block, arg_i.*, Type.fromInterned(param_ty), func_ty_info, func_inst);
                                                       ^
/Users/david/Code/zig/src/Sema.zig:7766:62: 0x1122e1b97 in analyzeCall (zig)
            const opt_noreturn_ref = try analyzeInlineCallArg(
                                                             ^
/Users/david/Code/zig/src/Sema.zig:7074:43: 0x11222e66b in zirCall__anon_331852 (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);
                                          ^
/Users/david/Code/zig/src/Sema.zig:1035:62: 0x111e0ecdf in analyzeBodyInner (zig)
            .call                         => try sema.zirCall(block, inst, .direct),
@rohlem

This comment was marked as outdated.

@Rexicon226 Rexicon226 changed the title ICE: generic poison when using anytime in function proto argument ICE: generic poison when using anytype in function proto argument Aug 16, 2024
@Vexu Vexu added bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness. labels Aug 18, 2024
@Vexu Vexu added this to the 0.15.0 milestone Aug 18, 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 frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Projects
None yet
Development

No branches or pull requests

3 participants