From 7695d51fc48b4bd82e1fe8da24162b28b2df19f1 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Mon, 3 Feb 2025 22:48:52 +0800 Subject: [PATCH] fixes #24658; cpp compilation failure on Nim 2.2.x (#24663) fixes #24658 --- compiler/semstmts.nim | 2 +- tests/cpp/tconstructor.nim | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index c4cd623d9bb95..9295b873c8108 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -2351,7 +2351,7 @@ proc semCppMember(c: PContext; s: PSym; n: PNode) = isInitializer = false break var j = 0 - while p[j].sym.kind == skParam: + while p[j].kind == nkSym and p[j].sym.kind == skParam: initializerCall.add val inc j if isInitializer: diff --git a/tests/cpp/tconstructor.nim b/tests/cpp/tconstructor.nim index 922ee54fd4565..2076b15d8d441 100644 --- a/tests/cpp/tconstructor.nim +++ b/tests/cpp/tconstructor.nim @@ -128,4 +128,10 @@ block: var b = makeBoo() var b2 = makeBoo2() - main() \ No newline at end of file + main() + +block: # bug #24658 + type + A {.importcpp: "A".} = object + + proc a(something: ptr cint = nil): A {.cdecl, constructor, importcpp: "A(@)".}