diff options
author | Clyybber <darkmine956@gmail.com> | 2020-04-30 02:01:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-30 02:01:07 +0200 |
commit | d6e1b5c070bf58449bf4af210ec099418d496aa5 (patch) | |
tree | c51d54904abc29c8cdad0c1d3f5417b04d9a11ab /compiler/ccgexprs.nim | |
parent | bd57f0cd3268843808c52614864a609703d9e611 (diff) | |
download | Nim-d6e1b5c070bf58449bf4af210ec099418d496aa5.tar.gz |
Fix #14160 (#14161)
* Fix #14160 * Add testcase
Diffstat (limited to 'compiler/ccgexprs.nim')
-rw-r--r-- | compiler/ccgexprs.nim | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 806eca744..0b9958ee4 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -2450,6 +2450,8 @@ proc genStmtList(p: BProc, n: PNode) = genStmtListExprImpl: genStmts(p, n[^1]) +from parampatterns import isLValue + proc upConv(p: BProc, n: PNode, d: var TLoc) = var a: TLoc initLocExpr(p, n[0], a) @@ -2468,7 +2470,11 @@ proc upConv(p: BProc, n: PNode, d: var TLoc) = linefmt(p, cpsStmts, "if (!#isObj($1, $2)){ #raiseObjectConversionError(); $3}$n", [r, checkFor, raiseInstr(p)]) if n[0].typ.kind != tyObject: - putIntoDest(p, d, n, + if n.isLValue: + putIntoDest(p, d, n, + "(*(($1*) (&($2))))" % [getTypeDesc(p.module, n.typ), rdLoc(a)], a.storage) + else: + putIntoDest(p, d, n, "(($1) ($2))" % [getTypeDesc(p.module, n.typ), rdLoc(a)], a.storage) else: putIntoDest(p, d, n, "(*($1*) ($2))" % |