From f8f6a3c9269da2862f74e53858cf9c0072ebbdc7 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Sun, 10 Sep 2023 23:35:40 +0800 Subject: [PATCH] renderIr should print the actual return assign node (#22682) follow up https://github.com/nim-lang/Nim/pull/10806 Eventually we need a new option to print high level IR. It's confusing when I'm debugging the compiler without showing `return result = 1` using the expandArc option. For ```nim proc foo: int = return 2 ``` It now outputs when expanding ARC IR ```nim proc foo: int = return result = 2 ``` --- compiler/renderer.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/renderer.nim b/compiler/renderer.nim index c73fa99451..41078716b1 100644 --- a/compiler/renderer.nim +++ b/compiler/renderer.nim @@ -586,7 +586,7 @@ proc lsub(g: TSrcGen; n: PNode): int = if n.len > 1: result = MaxLineLen + 1 else: result = lsons(g, n) + len("using_") of nkReturnStmt: - if n.len > 0 and n[0].kind == nkAsgn: + if n.len > 0 and n[0].kind == nkAsgn and renderIr notin g.flags: result = len("return_") + lsub(g, n[0][1]) else: result = len("return_") + lsub(g, n[0]) @@ -1635,7 +1635,7 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext, fromStmtList = false) = gsub(g, n[0]) of nkReturnStmt: putWithSpace(g, tkReturn, "return") - if n.len > 0 and n[0].kind == nkAsgn: + if n.len > 0 and n[0].kind == nkAsgn and renderIr notin g.flags: gsub(g, n[0], 1) else: gsub(g, n, 0)