From ee9e0d65e7fc55cba25a36ab8f117c2dfd39a645 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Wed, 15 Apr 2026 19:59:31 +0800 Subject: [PATCH] fixes #25469; Conversion from distinct in for forces a copy of underlying instance --- compiler/transf.nim | 5 ++++ tests/arc/tdistinct_for_nodup.nim | 41 +++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 tests/arc/tdistinct_for_nodup.nim diff --git a/compiler/transf.nim b/compiler/transf.nim index 399a8c468a..3059d8fe6b 100644 --- a/compiler/transf.nim +++ b/compiler/transf.nim @@ -702,6 +702,11 @@ proc putArgInto(arg: PNode, formal: PType): TPutArgInto = of nkAddr, nkHiddenAddr: result = putArgInto(arg[0], formal) if result == paViaIndirection: result = paFastAsgn + of nkHiddenStdConv, nkHiddenSubConv, nkConv: + if compareTypes(arg.typ, arg[1].typ, dcEqIgnoreDistinct, {IgnoreRangeShallow}): + result = putArgInto(arg[1], formal) + else: + result = paFastAsgn of nkCurly, nkBracket: for i in 0..