zig
zig copied to clipboard
stage2: Panic when instantiating generic function with tuple
Zig Version
0.10.0-dev.3363+0fc79d602
Steps to Reproduce
fn pair(x: f32, y: f32) std.meta.Tuple(&.{f32, f32}) {
return .{ x, y };
}
fn foo(_: anytype) void {}
test {
const x = comptime pair(1.5, 2.5);
foo(.{ x });
}
Expected Behavior
Test should pass, compiler should not panic
Actual Behavior
thread 13494 panic: reached unreachable code
Analyzing test.zig: test.zig:test_0
%36 = dbg_block_begin())
%37 = dbg_stmt(2, 5)
%39 = decl_val("pair")
%40 = dbg_stmt(2, 28)
%41 = param_type(%39, 0)
%42 = float(1.5)
%43 = param_type(%39, 1)
%44 = float(2.5)
%45 = call(.compile_time, %39, [%42, %44])
%47 = dbg_var_val(%45, "x")
%48 = dbg_stmt(3, 5)
%49 = decl_val("foo")
%50 = dbg_stmt(3, 8)
%51 = param_type(%49, 0)
%52 = array_init_anon(%45{})
%54 = dbg_block_end())
> %53 = call(nodiscard .auto, %49, [%52])
%55 = ret_tok(@Zir.Inst.Ref.void_value)
For full context, use the command
zig ast-check -t test.zig
/home/topolarity/repos/zig/src/value.zig:1545:21: 0xb1d6b6 in value.Value.toFloat (zig)
else => unreachable,
^
/home/topolarity/repos/zig/src/value.zig:2256:78: 0x13baf47 in value.Value.hash (zig)
32 => std.hash.autoHash(hasher, @bitCast(u32, val.toFloat(f32))),
^
/home/topolarity/repos/zig/src/value.zig:2298:39: 0x13bbaa0 in value.Value.hash (zig)
field_val.hash(fields.types[i], hasher, mod);
^
/home/topolarity/repos/zig/src/type.zig:1165:35: 0x11a22d7 in type.Type.hashWithHasher (zig)
field_val.hash(field_ty, hasher, mod);
^
/home/topolarity/repos/zig/src/Sema.zig:6125:38: 0x127efe4 in Sema.instantiateGenericCall (zig)
arg_ty.hashWithHasher(&hasher, mod);
^
/home/topolarity/repos/zig/src/Sema.zig:5551:40: 0x10ae8cc in Sema.analyzeCall (zig)
if (sema.instantiateGenericCall(
^
/home/topolarity/repos/zig/src/Sema.zig:5396:28: 0xe66f37 in Sema.zirCall (zig)
return sema.analyzeCall(block, func, func_src, call_src, modifier, ensure_result_used, resolved_args, bound_arg_src);
^
/home/topolarity/repos/zig/src/Sema.zig:717:62: 0xccd3a7 in Sema.analyzeBodyInner (zig)
.call => try sema.zirCall(block, inst),
^
/home/topolarity/repos/zig/src/Sema.zig:602:30: 0xcc10aa in Sema.analyzeBody (zig)
_ = sema.analyzeBodyInner(block, body) catch |err| switch (err) {
^
/home/topolarity/repos/zig/src/Module.zig:5393:21: 0xadba9d in Module.analyzeFnBody (zig)
sema.analyzeBody(&inner_block, fn_info.body) catch |err| switch (err) {
^
/home/topolarity/repos/zig/src/Module.zig:4121:40: 0xabe510 in Module.ensureFuncBodyAnalyzed (zig)
var air = mod.analyzeFnBody(func, sema_arena) catch |err| switch (err) {
^
/home/topolarity/repos/zig/src/Compilation.zig:2979:42: 0x7ee03a in Compilation.processOneJob (zig)
module.ensureFuncBodyAnalyzed(func) catch |err| switch (err) {
^
/home/topolarity/repos/zig/src/Compilation.zig:2911:30: 0x7d7b3d in Compilation.performAllTheWork (zig)
try processOneJob(comp, work_item);
^
/home/topolarity/repos/zig/src/Compilation.zig:2251:31: 0x7d0013 in Compilation.update (zig)
try comp.performAllTheWork(main_progress_node);
^
/home/topolarity/repos/zig/src/main.zig:3305:20: 0x73afdf in updateModule (zig)
try comp.update();
^
/home/topolarity/repos/zig/src/main.zig:2994:17: 0x702ff5 in buildOutputType (zig)
updateModule(gpa, comp, hook) catch |err| switch (err) {
^
/home/topolarity/repos/zig/src/main.zig:225:31: 0x6e6f46 in mainArgs (zig)
return buildOutputType(gpa, arena, args, .zig_test);
^
/home/topolarity/repos/zig/src/main.zig:174:20: 0x6e5f94 in main (zig)
return mainArgs(gpa, arena, args);
^
/home/topolarity/repos/zig/lib/std/start.zig:576:37: 0x6e885f in std.start.main (zig)
const result = root.main() catch |err| {
^
???:?:?: 0x7fe9db8957fc in ??? (???)
[1] 13494 IOT instruction ./stage2/bin/zig test test.zig