From 75e50f804a847023619692139a164afd6020e66b Mon Sep 17 00:00:00 2001 From: metagn Date: Sun, 6 Oct 2024 09:10:37 +0300 Subject: [PATCH] delay markUsed for converters until call is resolved (#24243) fixes #24241 (cherry picked from commit 09043f409f4e6f7b6f1f5e237d8c407f2d6a481b) --- compiler/sem.nim | 5 +++++ compiler/semcall.nim | 10 ++++++++++ compiler/semexprs.nim | 1 + compiler/sigmatch.nim | 4 +++- tests/converter/tdeprecatedconverter.nim | 14 ++++++++++++++ 5 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 tests/converter/tdeprecatedconverter.nim diff --git a/compiler/sem.nim b/compiler/sem.nim index 2cf93d365f..286dcc30fa 100644 --- a/compiler/sem.nim +++ b/compiler/sem.nim @@ -89,6 +89,11 @@ proc fitNodePostMatch(c: PContext, formal: PType, arg: PNode): PNode = changeType(c, x, formal, check=true) result = arg result = skipHiddenSubConv(result, c.graph, c.idgen) + # mark inserted converter as used: + var a = result + if a.kind == nkHiddenDeref: a = a[0] + if a.kind == nkHiddenCallConv and a[0].kind == nkSym: + markUsed(c, a.info, a[0].sym) proc fitNode(c: PContext, formal: PType, arg: PNode; info: TLineInfo): PNode = diff --git a/compiler/semcall.nim b/compiler/semcall.nim index 13f2273a9b..1f2b6bf2a0 100644 --- a/compiler/semcall.nim +++ b/compiler/semcall.nim @@ -645,6 +645,15 @@ proc instGenericConvertersSons*(c: PContext, n: PNode, x: TCandidate) = for i in 1..