parent
a541be8935
commit
36acac3000
2 changed files with 24 additions and 1 deletions
|
|
@ -198,6 +198,7 @@ proc genClosureCall(p: BProc, le, ri: PNode, d: var TLoc) =
|
||||||
var length = sonsLen(ri)
|
var length = sonsLen(ri)
|
||||||
for i in countup(1, length - 1):
|
for i in countup(1, length - 1):
|
||||||
assert(sonsLen(typ) == sonsLen(typ.n))
|
assert(sonsLen(typ) == sonsLen(typ.n))
|
||||||
|
if ri.sons[i].typ.isCompileTimeOnly: continue
|
||||||
if i < sonsLen(typ):
|
if i < sonsLen(typ):
|
||||||
assert(typ.n.sons[i].kind == nkSym)
|
assert(typ.n.sons[i].kind == nkSym)
|
||||||
app(pl, genArg(p, ri.sons[i], typ.n.sons[i].sym, ri))
|
app(pl, genArg(p, ri.sons[i], typ.n.sons[i].sym, ri))
|
||||||
|
|
@ -240,7 +241,9 @@ proc genClosureCall(p: BProc, le, ri: PNode, d: var TLoc) =
|
||||||
genCallPattern()
|
genCallPattern()
|
||||||
|
|
||||||
proc genOtherArg(p: BProc; ri: PNode; i: int; typ: PType): PRope =
|
proc genOtherArg(p: BProc; ri: PNode; i: int; typ: PType): PRope =
|
||||||
if i < sonsLen(typ):
|
if ri.sons[i].typ.isCompileTimeOnly:
|
||||||
|
result = nil
|
||||||
|
elif i < sonsLen(typ):
|
||||||
# 'var T' is 'T&' in C++. This means we ignore the request of
|
# 'var T' is 'T&' in C++. This means we ignore the request of
|
||||||
# any nkHiddenAddr when it's a 'var T'.
|
# any nkHiddenAddr when it's a 'var T'.
|
||||||
assert(typ.n.sons[i].kind == nkSym)
|
assert(typ.n.sons[i].kind == nkSym)
|
||||||
|
|
|
||||||
20
tests/cpp/tstaticvar_via_typedesc.nim
Normal file
20
tests/cpp/tstaticvar_via_typedesc.nim
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
discard """
|
||||||
|
cmd: "nim cpp $file"
|
||||||
|
output: "42"
|
||||||
|
"""
|
||||||
|
|
||||||
|
# bug #2324
|
||||||
|
|
||||||
|
static: assert defined(cpp), "compile in cpp mode"
|
||||||
|
|
||||||
|
{.emit: """
|
||||||
|
class Foo {
|
||||||
|
public:
|
||||||
|
static int x;
|
||||||
|
};
|
||||||
|
int Foo::x = 42;
|
||||||
|
""".}
|
||||||
|
|
||||||
|
type Foo {.importcpp:"Foo".} = object
|
||||||
|
proc x* (this: typedesc[Foo]): int {.importcpp:"Foo::x@", nodecl.}
|
||||||
|
echo Foo.x
|
||||||
Loading…
Add table
Add a link
Reference in a new issue