authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-06-21 13:33:58-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-06-21 17:03:04-07:00
logaf9a2c7c50802435213b1f7eab0874f08ea0f19a
tree99ce1aea836f6ba7429ef96d3949d6eb3056b74e
parentfee5aad699232d4feeece72f345d09d67faf1494

Sema: don't miscompile fns with inferred error sets


1 files changed, 12 insertions(+), 10 deletions(-)

src/Sema.zig+12-10
......@@ -1069,19 +1069,17 @@ fn zirOpaqueDecl(
10691069 inst: Zir.Inst.Index,
10701070 name_strategy: Zir.Inst.NameStrategy,
10711071) InnerError!*Inst {
1072 _ = name_strategy;
10731072 const tracy = trace(@src());
10741073 defer tracy.end();
10751074
10761075 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
10771076 const src = inst_data.src();
10781077 const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index);
1079 if (false) {
1080 inst_data;
1081 src;
1082 extra;
1083 }
10841078
1079 _ = name_strategy;
1080 _ = inst_data;
1081 _ = src;
1082 _ = extra;
10851083 return sema.mod.fail(&block.base, sema.src, "TODO implement zirOpaqueDecl", .{});
10861084}
10871085
......@@ -1244,8 +1242,7 @@ fn zirArg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*In
12441242
12451243 // TODO check if arg_name shadows a Decl
12461244
1247 if (block.inlining) |inlining| {
1248 _ = inlining;
1245 if (block.inlining) |_| {
12491246 return sema.param_inst_list[arg_index];
12501247 }
12511248
......@@ -3067,7 +3064,6 @@ fn funcCommon(
30673064 src_locs: Zir.Inst.Func.SrcLocs,
30683065 opt_lib_name: ?[]const u8,
30693066) InnerError!*Inst {
3070 _ = inferred_error_set;
30713067 const src: LazySrcLoc = .{ .node_offset = src_node_offset };
30723068 const ret_ty_src: LazySrcLoc = .{ .node_offset_fn_type_ret_ty = src_node_offset };
30733069 const return_type = try sema.resolveType(block, ret_ty_src, zir_return_type);
......@@ -3076,7 +3072,9 @@ fn funcCommon(
30763072
30773073 const fn_ty: Type = fn_ty: {
30783074 // Hot path for some common function types.
3079 if (zir_param_types.len == 0 and !var_args and align_val.tag() == .null_value) {
3075 if (zir_param_types.len == 0 and !var_args and align_val.tag() == .null_value and
3076 !inferred_error_set)
3077 {
30803078 if (return_type.zigTypeTag() == .NoReturn and cc == .Unspecified) {
30813079 break :fn_ty Type.initTag(.fn_noreturn_no_args);
30823080 }
......@@ -3107,6 +3105,10 @@ fn funcCommon(
31073105 return mod.fail(&block.base, src, "TODO implement support for function prototypes to have alignment specified", .{});
31083106 }
31093107
3108 if (inferred_error_set) {
3109 return mod.fail(&block.base, src, "TODO implement functions with inferred error sets", .{});
3110 }
3111
31103112 break :fn_ty try Type.Tag.function.create(sema.arena, .{
31113113 .param_types = param_types,
31123114 .return_type = return_type,