| author | |
| committer | |
| log | f983adfc1076adc8509458c4bb64102c797041ff |
| tree | c3f29f96fce9b11006e1d774b6f28ae160c6d632 |
| parent | 294f51814f491ae4a09348d9e7221ae3e550c16f |
Closes #193324 files changed, 24 insertions(+), 4 deletions(-)
src/Module.zig+5-2| ... | ... | @@ -1897,8 +1897,11 @@ pub const SrcLoc = struct { |
| 1897 | 1897 | const parent_node = src_loc.declRelativeToNodeIndex(node_off); |
| 1898 | 1898 | |
| 1899 | 1899 | var buf: [2]Ast.Node.Index = undefined; |
| 1900 | const full = tree.fullArrayInit(&buf, parent_node).?; | |
| 1901 | return tree.nodeToSpan(full.ast.type_expr); | |
| 1900 | const type_expr = if (tree.fullArrayInit(&buf, parent_node)) |array_init| | |
| 1901 | array_init.ast.type_expr | |
| 1902 | else | |
| 1903 | tree.fullStructInit(&buf, parent_node).?.ast.type_expr; | |
| 1904 | return tree.nodeToSpan(type_expr); | |
| 1902 | 1905 | }, |
| 1903 | 1906 | .node_offset_store_ptr => |node_off| { |
| 1904 | 1907 | const tree = try src_loc.file_scope.getTree(gpa); |
src/Sema.zig+2-1| ... | ... | @@ -19753,7 +19753,8 @@ fn zirStructInitEmpty(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE |
| 19753 | 19753 | |
| 19754 | 19754 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 19755 | 19755 | const src = inst_data.src(); |
| 19756 | const obj_ty = try sema.resolveType(block, src, inst_data.operand); | |
| 19756 | const ty_src: LazySrcLoc = .{ .node_offset_init_ty = inst_data.src_node }; | |
| 19757 | const obj_ty = try sema.resolveType(block, ty_src, inst_data.operand); | |
| 19757 | 19758 | const mod = sema.mod; |
| 19758 | 19759 | |
| 19759 | 19760 | switch (obj_ty.zigTypeTag(mod)) { |
src/type.zig+5-1| ... | ... | @@ -254,7 +254,11 @@ pub const Type = struct { |
| 254 | 254 | .error_union_type => |error_union_type| { |
| 255 | 255 | try print(Type.fromInterned(error_union_type.error_set_type), writer, mod); |
| 256 | 256 | try writer.writeByte('!'); |
| 257 | try print(Type.fromInterned(error_union_type.payload_type), writer, mod); | |
| 257 | if (error_union_type.payload_type == .generic_poison_type) { | |
| 258 | try writer.writeAll("anytype"); | |
| 259 | } else { | |
| 260 | try print(Type.fromInterned(error_union_type.payload_type), writer, mod); | |
| 261 | } | |
| 258 | 262 | return; |
| 259 | 263 | }, |
| 260 | 264 | .inferred_error_set_type => |func_index| { |
test/cases/compile_errors/array_init_generic_fn_with_inferred_error_set.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | pub export fn entry() void { | |
| 2 | _ = my_func{u8} catch {}; | |
| 3 | } | |
| 4 | pub export fn entry1() void { | |
| 5 | _ = my_func{} catch {}; | |
| 6 | } | |
| 7 | fn my_func(comptime T: type) !T {} | |
| 8 | ||
| 9 | // error | |
| 10 | // | |
| 11 | // :2:9: error: expected type 'type', found 'fn (comptime type) @typeInfo(@typeInfo(@TypeOf(tmp.my_func)).Fn.return_type.?).ErrorUnion.error_set!anytype' | |
| 12 | // :5:9: error: expected type 'type', found 'fn (comptime type) @typeInfo(@typeInfo(@TypeOf(tmp.my_func)).Fn.return_type.?).ErrorUnion.error_set!anytype' |