Skip to content

Commit

Permalink
fixes #20958; fixes the return type of slice function [backport] (#20959
Browse files Browse the repository at this point in the history
)

* fixes #20958; fixes the return type of slice function

* add a testcase
  • Loading branch information
ringabout authored Nov 29, 2022
1 parent d4afa53 commit 3d5edb4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions compiler/semparallel.nim
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,9 @@ proc transformSlices(g: ModuleGraph; idgen: IdGenerator; n: PNode): PNode =
let op = n[0].sym
if op.name.s == "[]" and op.fromSystem:
result = copyNode(n)
var typ = newType(tyOpenArray, nextTypeId(g.idgen), result.typ.owner)
typ.add result.typ[0]
result.typ = typ
let opSlice = newSymNode(createMagic(g, idgen, "slice", mSlice))
opSlice.typ = getSysType(g, n.info, tyInt)
result.add opSlice
Expand Down
12 changes: 12 additions & 0 deletions tests/parallel/tsimple_array_checks.nim
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,15 @@ maino() # Doesn't work outside a proc

when true:
main()

block two:
proc f(a: openArray[int]) =
discard

proc main() =
var a: array[0..9, int] = [0,1,2,3,4,5,6,7,8,9]
parallel:
spawn f(a[0..2])


main()

0 comments on commit 3d5edb4

Please sign in to comment.