We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 09f36f5 commit 6128ef5Copy full SHA for 6128ef5
compiler/ccgexprs.nim
@@ -1882,8 +1882,17 @@ proc genArrayLen(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
1882
if op == mHigh: unaryExpr(p, e, d, "($1Len_0-1)")
1883
else: unaryExpr(p, e, d, "$1Len_0")
1884
else:
1885
- if op == mHigh: unaryExpr(p, e, d, "($1.Field1-1)")
1886
- else: unaryExpr(p, e, d, "$1.Field1")
+ let isDeref = a.kind in {nkHiddenDeref, nkDerefExpr}
+ if op == mHigh:
1887
+ if isDeref:
1888
+ unaryExpr(p, e, d, "($1->Field1-1)")
1889
+ else:
1890
+ unaryExpr(p, e, d, "($1.Field1-1)")
1891
1892
1893
+ unaryExpr(p, e, d, "$1->Field1")
1894
1895
+ unaryExpr(p, e, d, "$1.Field1")
1896
of tyCstring:
1897
if op == mHigh: unaryExpr(p, e, d, "($1 ? (#nimCStrLen($1)-1) : -1)")
1898
else: unaryExpr(p, e, d, "($1 ? #nimCStrLen($1) : 0)")
tests/ccgbugs/t10964.nim
@@ -0,0 +1,6 @@
1
+func test*(input: var openArray[int32], start: int = 0, fin: int = input.len - 1) =
2
+ discard
3
+
4
+var someSeq = @[1'i32]
5
6
+test(someSeq)
0 commit comments