authorgravatar for curtistatewilkinson@gmail.comCurtis Wilkinson <curtistatewilkinson@gmail.com> 2022-03-02 17:51:46+10:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-02 14:46:09-05:00
log7fc8dd66427dd0abed5ca9195e6afdbb687bd5f5
treee025b298b28a20c70c4e4ab766b11a1c8c881b95
parent5c8a507e7a8e2e58a0ca855689bcd2edd2ab6ab8

Zir: rename the 'ret_coerce' tag to 'ret_tok' as per TODO


4 files changed, 11 insertions(+), 13 deletions(-)

src/AstGen.zig+5-5
......@@ -2303,7 +2303,7 @@ fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: Ast.Node.Index) Inner
23032303 .compile_error,
23042304 .ret_node,
23052305 .ret_load,
2306 .ret_coerce,
2306 .ret_tok,
23072307 .ret_err_value,
23082308 .@"unreachable",
23092309 .repeat,
......@@ -3420,8 +3420,8 @@ fn fnDecl(
34203420
34213421 if (!fn_gz.endsWithNoReturn()) {
34223422 // Since we are adding the return instruction here, we must handle the coercion.
3423 // We do this by using the `ret_coerce` instruction.
3424 _ = try fn_gz.addUnTok(.ret_coerce, .void_value, tree.lastToken(body_node));
3423 // We do this by using the `ret_tok` instruction.
3424 _ = try fn_gz.addUnTok(.ret_tok, .void_value, tree.lastToken(body_node));
34253425 }
34263426
34273427 break :func try decl_gz.addFunc(.{
......@@ -3850,8 +3850,8 @@ fn testDecl(
38503850 const block_result = try expr(&fn_block, &fn_block.base, .none, body_node);
38513851 if (fn_block.isEmpty() or !fn_block.refIsNoReturn(block_result)) {
38523852 // Since we are adding the return instruction here, we must handle the coercion.
3853 // We do this by using the `ret_coerce` instruction.
3854 _ = try fn_block.addUnTok(.ret_coerce, .void_value, tree.lastToken(body_node));
3853 // We do this by using the `ret_tok` instruction.
3854 _ = try fn_block.addUnTok(.ret_tok, .void_value, tree.lastToken(body_node));
38553855 }
38563856
38573857 const func_inst = try decl_block.addFunc(.{
src/Sema.zig+2-2
......@@ -812,7 +812,7 @@ fn analyzeBodyInner(
812812 // These functions match the return type of analyzeBody so that we can
813813 // tail call them here.
814814 .compile_error => break sema.zirCompileError(block, inst),
815 .ret_coerce => break sema.zirRetCoerce(block, inst),
815 .ret_tok => break sema.zirRetTok(block, inst),
816816 .ret_node => break sema.zirRetNode(block, inst),
817817 .ret_load => break sema.zirRetLoad(block, inst),
818818 .ret_err_value => break sema.zirRetErrValue(block, inst),
......@@ -11189,7 +11189,7 @@ fn zirRetErrValue(
1118911189 return sema.analyzeRet(block, result_inst, src);
1119011190}
1119111191
11192fn zirRetCoerce(
11192fn zirRetTok(
1119311193 sema: *Sema,
1119411194 block: *Block,
1119511195 inst: Zir.Inst.Index,
src/Zir.zig+3-5
......@@ -477,9 +477,7 @@ pub const Inst = struct {
477477 /// Includes an operand as the return value.
478478 /// Includes a token source location.
479479 /// Uses the `un_tok` union field.
480 /// The operand needs to get coerced to the function's return type.
481 /// TODO rename this to `ret_tok` because coercion is now done unconditionally in Sema.
482 ret_coerce,
480 ret_tok,
483481 /// Sends control flow back to the function's callee.
484482 /// The return operand is `error.foo` where `foo` is given by the string.
485483 /// If the current function has an inferred error set, the error given by the
......@@ -1217,7 +1215,7 @@ pub const Inst = struct {
12171215 .compile_error,
12181216 .ret_node,
12191217 .ret_load,
1220 .ret_coerce,
1218 .ret_tok,
12211219 .ret_err_value,
12221220 .@"unreachable",
12231221 .repeat,
......@@ -1323,7 +1321,7 @@ pub const Inst = struct {
13231321 .ref = .un_tok,
13241322 .ret_node = .un_node,
13251323 .ret_load = .un_node,
1326 .ret_coerce = .un_tok,
1324 .ret_tok = .un_tok,
13271325 .ret_err_value = .str_tok,
13281326 .ret_err_value_code = .str_tok,
13291327 .ptr_type_simple = .ptr_type_simple,
src/print_zir.zig+1-1
......@@ -241,7 +241,7 @@ const Writer = struct {
241241 => try self.writeUnNode(stream, inst),
242242
243243 .ref,
244 .ret_coerce,
244 .ret_tok,
245245 .ensure_err_payload_void,
246246 .closure_capture,
247247 => try self.writeUnTok(stream, inst),