mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 22:35:24 +00:00
parent
294f51814f
commit
f983adfc10
@ -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);
|
||||
|
||||
@ -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)) {
|
||||
|
||||
@ -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| {
|
||||
|
||||
@ -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'
|
||||
Loading…
x
Reference in New Issue
Block a user