diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2022-11-29 14:21:44 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-29 07:21:44 +0100 |
commit | 3d5edb41bea9cebd5aabddefde0797ba2026dd7b (patch) | |
tree | 4b70b7bf35dbf33b564829e8bfceb766f6920fbe | |
parent | d4afa53fd5fca70e4a09bb19bf34523b522ce309 (diff) | |
download | Nim-3d5edb41bea9cebd5aabddefde0797ba2026dd7b.tar.gz |
fixes #20958; fixes the return type of slice function [backport] (#20959)
* fixes #20958; fixes the return type of slice function * add a testcase
-rw-r--r-- | compiler/semparallel.nim | 3 | ||||
-rw-r--r-- | tests/parallel/tsimple_array_checks.nim | 12 |
2 files changed, 15 insertions, 0 deletions
diff --git a/compiler/semparallel.nim b/compiler/semparallel.nim index 540a06c40..ced479dbe 100644 --- a/compiler/semparallel.nim +++ b/compiler/semparallel.nim @@ -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 diff --git a/tests/parallel/tsimple_array_checks.nim b/tests/parallel/tsimple_array_checks.nim index 650b809e0..ab292f935 100644 --- a/tests/parallel/tsimple_array_checks.nim +++ b/tests/parallel/tsimple_array_checks.nim @@ -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() \ No newline at end of file |