From 0cdbf5e04eeb8b5eb4ac706282563d3623ea5e2f Mon Sep 17 00:00:00 2001 From: Jake Leahy Date: Mon, 28 Nov 2022 06:09:25 +1100 Subject: [PATCH] Add `nkFastAsgn` into `semExpr` (#20939) * Add nkFastAsgn into case statement * Add test case (cherry picked from commit d26b1232ee7a69c2a71db81aa0185499321c54fe) --- compiler/semexprs.nim | 2 +- tests/magics/t20938.nim | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/magics/t20938.nim diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 76bc756e16..abab6fe44f 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -3005,7 +3005,7 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode = # the node is left intact for now discard of nkStaticExpr: result = semStaticExpr(c, n[0]) - of nkAsgn: result = semAsgn(c, n) + of nkAsgn, nkFastAsgn: result = semAsgn(c, n) of nkBlockStmt, nkBlockExpr: result = semBlock(c, n, flags) of nkStmtList, nkStmtListExpr: result = semStmtList(c, n, flags) of nkRaiseStmt: result = semRaise(c, n) diff --git a/tests/magics/t20938.nim b/tests/magics/t20938.nim new file mode 100644 index 0000000000..7341cbb917 --- /dev/null +++ b/tests/magics/t20938.nim @@ -0,0 +1,12 @@ +discard """ + cmd: "nim c --mm:refc $file" + action: "compile" +""" + +template foo(x: typed) = + discard x + +foo: + var x = "hello" + x.shallowCopy("test") + true