parent
784720a7ef
commit
47ce24f680
3 changed files with 26 additions and 2 deletions
|
|
@ -1074,8 +1074,13 @@ proc genAsgnAux(p: PProc, x, y: PNode, noCopyNeeded: bool) =
|
||||||
lineF(p, "$1 = $2;$n", [a.rdLoc, b.rdLoc])
|
lineF(p, "$1 = $2;$n", [a.rdLoc, b.rdLoc])
|
||||||
else:
|
else:
|
||||||
useMagic(p, "nimCopy")
|
useMagic(p, "nimCopy")
|
||||||
|
# supports proc getF(): var T
|
||||||
|
if x.kind in {nkHiddenDeref, nkDerefExpr} and x[0].kind in nkCallKinds:
|
||||||
lineF(p, "nimCopy($1, $2, $3);$n",
|
lineF(p, "nimCopy($1, $2, $3);$n",
|
||||||
[a.res, b.res, genTypeInfo(p, y.typ)])
|
[a.res, b.res, genTypeInfo(p, y.typ)])
|
||||||
|
else:
|
||||||
|
lineF(p, "$1 = nimCopy($1, $2, $3);$n",
|
||||||
|
[a.res, b.res, genTypeInfo(p, y.typ)])
|
||||||
of etyBaseIndex:
|
of etyBaseIndex:
|
||||||
if a.typ != etyBaseIndex or b.typ != etyBaseIndex:
|
if a.typ != etyBaseIndex or b.typ != etyBaseIndex:
|
||||||
if y.kind == nkCall:
|
if y.kind == nkCall:
|
||||||
|
|
|
||||||
16
tests/js/t12303.nim
Normal file
16
tests/js/t12303.nim
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
discard """
|
||||||
|
output: "{ b: 2 }"
|
||||||
|
"""
|
||||||
|
|
||||||
|
import jsconsole, jsffi
|
||||||
|
|
||||||
|
type
|
||||||
|
A = ref object
|
||||||
|
b: B
|
||||||
|
|
||||||
|
B = object
|
||||||
|
b: int
|
||||||
|
|
||||||
|
var a = cast[A](js{})
|
||||||
|
a.b = B(b: 2)
|
||||||
|
console.log a.b
|
||||||
|
|
@ -4,6 +4,7 @@ discard """
|
||||||
123
|
123
|
||||||
1234
|
1234
|
||||||
12345
|
12345
|
||||||
|
123456
|
||||||
'''
|
'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -28,6 +29,8 @@ getF().a = 1234
|
||||||
echo getF().a
|
echo getF().a
|
||||||
getF() = Foo(a: 12345)
|
getF() = Foo(a: 12345)
|
||||||
echo getF().a
|
echo getF().a
|
||||||
|
(addr getF())[] = Foo(a: 123456)
|
||||||
|
echo getF().a
|
||||||
|
|
||||||
|
|
||||||
block: # #13848
|
block: # #13848
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue