Skip to content

Commit 2114414

Browse files
ringaboutnarimiran
authored andcommitted
fixes #19977; rework inlining of 'var openarray' iterators for C++ (#23258)
fixes #19977 (cherry picked from commit f7c6e04)
1 parent 3788aa0 commit 2114414

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

compiler/transf.nim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,8 @@ proc transformYield(c: PTransf, n: PNode): PNode =
472472

473473
proc transformAddrDeref(c: PTransf, n: PNode, kinds: TNodeKinds): PNode =
474474
result = transformSons(c, n)
475-
if c.graph.config.backend == backendCpp or sfCompileToCpp in c.module.flags: return
475+
# inlining of 'var openarray' iterators; bug #19977
476+
if n.typ.kind != tyOpenArray and (c.graph.config.backend == backendCpp or sfCompileToCpp in c.module.flags): return
476477
var n = result
477478
case n[0].kind
478479
of nkObjUpConv, nkObjDownConv, nkChckRange, nkChckRangeF, nkChckRange64:

tests/iter/titervaropenarray.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
discard """
22
output: "123"
3-
targets: "c"
3+
targets: "c cpp"
44
"""
55
# Try to break the transformation pass:
66
iterator iterAndZero(a: var openArray[int]): int =

0 commit comments

Comments
 (0)