From 6d59680217cfbd9314cf62d1d07adc8e6e552d53 Mon Sep 17 00:00:00 2001 From: metagn Date: Wed, 22 Jan 2025 16:08:21 +0300 Subject: [PATCH] don't try to transform objconstr/cast type nodes (#24636) fixes #24631 [Object constructors](https://github.com/nim-lang/Nim/blob/793baf34ff72cb8c5485ce209af086e27f656853/compiler/semobjconstr.nim#L462), [casts](https://github.com/nim-lang/Nim/blob/793baf34ff72cb8c5485ce209af086e27f656853/compiler/semexprs.nim#L494) and [type conversions](https://github.com/nim-lang/Nim/blob/793baf34ff72cb8c5485ce209af086e27f656853/compiler/semexprs.nim#L419) copy their type nodes verbatim instead of producing semchecked type nodes. This causes a crash in transf when an untyped expression in the type node has `nil` type. To deal with this, don't try to transform the type node in these expressions at all. I couldn't reproduce the problem with type conversion nodes though so those are unchanged in transf. --- compiler/transf.nim | 10 ++++++++++ tests/template/tgenericobjconstr.nim | 15 +++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tests/template/tgenericobjconstr.nim diff --git a/compiler/transf.nim b/compiler/transf.nim index 5cf43e6a3f..433a534912 100644 --- a/compiler/transf.nim +++ b/compiler/transf.nim @@ -106,6 +106,13 @@ proc transformSons(c: PTransf, n: PNode, noConstFold = false): PNode = for i in 0..