mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 05:50:30 +00:00
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
This commit is contained in:
27
tests/cpp/tpassbypragmas.nim
Normal file
27
tests/cpp/tpassbypragmas.nim
Normal file
@@ -0,0 +1,27 @@
|
||||
discard """
|
||||
targets: "cpp"
|
||||
cmd: "nim cpp $file"
|
||||
"""
|
||||
{.emit:"""/*TYPESECTION*/
|
||||
|
||||
template<typename T>
|
||||
struct Box {
|
||||
T first;
|
||||
};
|
||||
struct Foo {
|
||||
void test(void (*func)(Box<Foo>& 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)
|
||||
Reference in New Issue
Block a user