Skip to content

Commit

Permalink
fixes explicit deref block (nim-lang#22093)
Browse files Browse the repository at this point in the history
fixes explicit deref
  • Loading branch information
ringabout authored Jun 15, 2023
1 parent d90581c commit edb64bc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 0 additions & 2 deletions compiler/ccgexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -754,8 +754,6 @@ proc isCppRef(p: BProc; typ: PType): bool {.inline.} =
tfVarIsPtr notin skipTypes(typ, abstractInstOwned).flags

proc genDeref(p: BProc, e: PNode, d: var TLoc) =
assert e[0].kind notin {nkBlockExpr, nkBlockStmt}, "it should have been transformed in transf"

let mt = mapType(p.config, e[0].typ, mapTypeChooser(e[0]) == skParam)
if mt in {ctArray, ctPtrToArray} and lfEnforceDeref notin d.flags:
# XXX the amount of hacks for C's arrays is incredible, maybe we should
Expand Down
4 changes: 3 additions & 1 deletion compiler/transf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,9 @@ proc transform(c: PTransf, n: PNode): PNode =
result = transformAddrDeref(c, n, {nkHiddenDeref})
of nkAddr:
result = transformAddrDeref(c, n, {nkDerefExpr, nkHiddenDeref})
of nkDerefExpr, nkHiddenDeref:
of nkDerefExpr:
result = transformAddrDeref(c, n, {nkAddr, nkHiddenAddr})
of nkHiddenDeref:
if n[0].kind in {nkBlockExpr, nkBlockStmt}:
# bug #20107 bug #21540. Watch out to not deref the pointer too late.
let e = transformDerefBlock(c, n)
Expand Down

0 comments on commit edb64bc

Please sign in to comment.