srctree

Veikka Tuominen parent 294f5181 f983adfc
Sema: fix printing of inferred error set of generic fn

Closes #19332

inlinesplit
src/Module.zig added: 28, removed: 8, total 20
@@ -1897,8 +1897,11 @@ pub const SrcLoc = struct {
const parent_node = src_loc.declRelativeToNodeIndex(node_off);
 
var buf: [2]Ast.Node.Index = undefined;
const full = tree.fullArrayInit(&buf, parent_node).?;
return tree.nodeToSpan(full.ast.type_expr);
const type_expr = if (tree.fullArrayInit(&buf, parent_node)) |array_init|
array_init.ast.type_expr
else
tree.fullStructInit(&buf, parent_node).?.ast.type_expr;
return tree.nodeToSpan(type_expr);
},
.node_offset_store_ptr => |node_off| {
const tree = try src_loc.file_scope.getTree(gpa);
 
src/Sema.zig added: 28, removed: 8, total 20
@@ -19753,7 +19753,8 @@ fn zirStructInitEmpty(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
 
const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
const src = inst_data.src();
const obj_ty = try sema.resolveType(block, src, inst_data.operand);
const ty_src: LazySrcLoc = .{ .node_offset_init_ty = inst_data.src_node };
const obj_ty = try sema.resolveType(block, ty_src, inst_data.operand);
const mod = sema.mod;
 
switch (obj_ty.zigTypeTag(mod)) {
 
src/type.zig added: 28, removed: 8, total 20
@@ -254,7 +254,11 @@ pub const Type = struct {
.error_union_type => |error_union_type| {
try print(Type.fromInterned(error_union_type.error_set_type), writer, mod);
try writer.writeByte('!');
try print(Type.fromInterned(error_union_type.payload_type), writer, mod);
if (error_union_type.payload_type == .generic_poison_type) {
try writer.writeAll("anytype");
} else {
try print(Type.fromInterned(error_union_type.payload_type), writer, mod);
}
return;
},
.inferred_error_set_type => |func_index| {
 
filename was Deleted added: 28, removed: 8, total 20
@@ -0,0 +1,12 @@
pub export fn entry() void {
_ = my_func{u8} catch {};
}
pub export fn entry1() void {
_ = my_func{} catch {};
}
fn my_func(comptime T: type) !T {}
 
// error
//
// :2:9: error: expected type 'type', found 'fn (comptime type) @typeInfo(@typeInfo(@TypeOf(tmp.my_func)).Fn.return_type.?).ErrorUnion.error_set!anytype'
// :5:9: error: expected type 'type', found 'fn (comptime type) @typeInfo(@typeInfo(@TypeOf(tmp.my_func)).Fn.return_type.?).ErrorUnion.error_set!anytype'