From e70992d2910e418e3e6d51ae097558ca123e354e Mon Sep 17 00:00:00 2001 From: Juan M Gómez Date: Sat, 29 Jul 2023 17:05:31 +0100 Subject: fixes an issue where byref wasnt properly handled when using it in a generic param (#22337) * fixes an issue where byref wasnt properly handled when using it in a generic param * removes unreachable check --- tests/cpp/tpassbypragmas.nim | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/cpp/tpassbypragmas.nim (limited to 'tests/cpp') diff --git a/tests/cpp/tpassbypragmas.nim b/tests/cpp/tpassbypragmas.nim new file mode 100644 index 000000000..f4301656a --- /dev/null +++ b/tests/cpp/tpassbypragmas.nim @@ -0,0 +1,27 @@ +discard """ + targets: "cpp" + cmd: "nim cpp $file" +""" +{.emit:"""/*TYPESECTION*/ + + template + struct Box { + T first; + }; + struct Foo { + void test(void (*func)(Box& another)){ + + }; + }; +""".} + +type + Foo {.importcpp.} = object + Box[T] {.importcpp:"Box<'0>".} = object + first: T + +proc test(self: Foo, fn: proc(another {.byref.}: Box[Foo]) {.cdecl.}) {.importcpp.} + +proc fn(another {.byref.} : Box[Foo]) {.cdecl.} = discard + +Foo().test(fn) \ No newline at end of file -- cgit 1.4.1-2-gfad0