mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-20 06:20:38 +00:00
fix #12521(type alias for openArray) (#17593)
* fix nim js cmp fails at CT * fix #12521 * address comments
This commit is contained in:
@@ -23,5 +23,31 @@ proc main =
|
||||
when defined(js): discard # xxx bug #15952: `a` left unchanged
|
||||
else: doAssert a == [1, 0, 10, 20, 5]
|
||||
|
||||
block: # bug #12521
|
||||
block:
|
||||
type slice[T] = openArray[T]
|
||||
|
||||
# Proc using that alias
|
||||
proc testing(sl: slice[int]): seq[int] =
|
||||
for item in sl:
|
||||
result.add item
|
||||
|
||||
let mySeq = @[1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||
doAssert testing(mySeq) == mySeq
|
||||
doAssert testing(mySeq[2..^2]) == mySeq[2..^2]
|
||||
|
||||
block:
|
||||
type slice = openArray[int]
|
||||
|
||||
# Proc using that alias
|
||||
proc testing(sl: slice): seq[int] =
|
||||
for item in sl:
|
||||
result.add item
|
||||
|
||||
let mySeq = @[1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||
doAssert testing(mySeq) == mySeq
|
||||
doAssert testing(mySeq[2..^2]) == mySeq[2..^2]
|
||||
|
||||
|
||||
main()
|
||||
# static: main() # xxx bug #15952: Error: cannot generate code for: mSlice
|
||||
|
||||
Reference in New Issue
Block a user