diff options
-rw-r--r-- | lib/core/macros.nim | 2 | ||||
-rw-r--r-- | lib/system.nim | 12 | ||||
-rw-r--r-- | lib/system/iterators.nim | 2 | ||||
-rw-r--r-- | tests/errmsgs/t10735.nim | 6 |
4 files changed, 11 insertions, 11 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim index e579d6b30..6e1089b39 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -175,7 +175,7 @@ proc `[]`*(n: NimNode, i: BackwardsIndex): NimNode = n[n.len - i.int] template `^^`(n: NimNode, i: untyped): untyped = (when i is BackwardsIndex: n.len - int(i) else: int(i)) -proc `[]`*[T, U](n: NimNode, x: HSlice[T, U]): seq[NimNode] = +proc `[]`*[T, U: Ordinal](n: NimNode, x: HSlice[T, U]): seq[NimNode] = ## Slice operation for NimNode. ## Returns a seq of child of `n` who inclusive range [n[x.a], n[x.b]]. let xa = n ^^ x.a diff --git a/lib/system.nim b/lib/system.nim index db7cf3482..e5ef54fa4 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -2498,7 +2498,7 @@ template `^^`(s, i: untyped): untyped = template `[]`*(s: string; i: int): char = arrGet(s, i) template `[]=`*(s: string; i: int; val: char) = arrPut(s, i, val) -proc `[]`*[T, U](s: string, x: HSlice[T, U]): string {.inline.} = +proc `[]`*[T, U: Ordinal](s: string, x: HSlice[T, U]): string {.inline.} = ## Slice operation for strings. ## Returns the inclusive range `[s[x.a], s[x.b]]`: ## @@ -2510,7 +2510,7 @@ proc `[]`*[T, U](s: string, x: HSlice[T, U]): string {.inline.} = result = newString(L) for i in 0 ..< L: result[i] = s[i + a] -proc `[]=`*[T, U](s: var string, x: HSlice[T, U], b: string) = +proc `[]=`*[T, U: Ordinal](s: var string, x: HSlice[T, U], b: string) = ## Slice assignment for strings. ## ## If ``b.len`` is not exactly the number of elements that are referred to @@ -2528,7 +2528,7 @@ proc `[]=`*[T, U](s: var string, x: HSlice[T, U], b: string) = else: spliceImpl(s, a, L, b) -proc `[]`*[Idx, T, U, V](a: array[Idx, T], x: HSlice[U, V]): seq[T] = +proc `[]`*[Idx, T; U, V: Ordinal](a: array[Idx, T], x: HSlice[U, V]): seq[T] = ## Slice operation for arrays. ## Returns the inclusive range `[a[x.a], a[x.b]]`: ## @@ -2540,7 +2540,7 @@ proc `[]`*[Idx, T, U, V](a: array[Idx, T], x: HSlice[U, V]): seq[T] = result = newSeq[T](L) for i in 0..<L: result[i] = a[Idx(i + xa)] -proc `[]=`*[Idx, T, U, V](a: var array[Idx, T], x: HSlice[U, V], b: openArray[T]) = +proc `[]=`*[Idx, T; U, V: Ordinal](a: var array[Idx, T], x: HSlice[U, V], b: openArray[T]) = ## Slice assignment for arrays. ## ## .. code-block:: Nim @@ -2554,7 +2554,7 @@ proc `[]=`*[Idx, T, U, V](a: var array[Idx, T], x: HSlice[U, V], b: openArray[T] else: sysFatal(RangeDefect, "different lengths for slice assignment") -proc `[]`*[T, U, V](s: openArray[T], x: HSlice[U, V]): seq[T] = +proc `[]`*[T; U, V: Ordinal](s: openArray[T], x: HSlice[U, V]): seq[T] = ## Slice operation for sequences. ## Returns the inclusive range `[s[x.a], s[x.b]]`: ## @@ -2566,7 +2566,7 @@ proc `[]`*[T, U, V](s: openArray[T], x: HSlice[U, V]): seq[T] = newSeq(result, L) for i in 0 ..< L: result[i] = s[i + a] -proc `[]=`*[T, U, V](s: var seq[T], x: HSlice[U, V], b: openArray[T]) = +proc `[]=`*[T; U, V: Ordinal](s: var seq[T], x: HSlice[U, V], b: openArray[T]) = ## Slice assignment for sequences. ## ## If ``b.len`` is not exactly the number of elements that are referred to diff --git a/lib/system/iterators.nim b/lib/system/iterators.nim index c8c0edbd4..b5d7d1b62 100644 --- a/lib/system/iterators.nim +++ b/lib/system/iterators.nim @@ -87,7 +87,7 @@ iterator items*[T: enum](E: typedesc[T]): T = for v in low(E) .. high(E): yield v -iterator items*[T](s: HSlice[T, T]): T = +iterator items*[T: Ordinal](s: Slice[T]): T = ## Iterates over the slice `s`, yielding each value between `s.a` and `s.b` ## (inclusively). for x in s.a .. s.b: diff --git a/tests/errmsgs/t10735.nim b/tests/errmsgs/t10735.nim index 514c4f101..307acac2d 100644 --- a/tests/errmsgs/t10735.nim +++ b/tests/errmsgs/t10735.nim @@ -12,15 +12,15 @@ proc `[]`(s: var string; i: BackwardsIndex): var char first type mismatch at position: 0 proc `[]`[I: Ordinal; T](a: T; i: I): T first type mismatch at position: 0 -proc `[]`[Idx, T, U, V](a: array[Idx, T]; x: HSlice[U, V]): seq[T] +proc `[]`[Idx, T; U, V: Ordinal](a: array[Idx, T]; x: HSlice[U, V]): seq[T] first type mismatch at position: 0 proc `[]`[Idx, T](a: array[Idx, T]; i: BackwardsIndex): T first type mismatch at position: 0 proc `[]`[Idx, T](a: var array[Idx, T]; i: BackwardsIndex): var T first type mismatch at position: 0 -proc `[]`[T, U, V](s: openArray[T]; x: HSlice[U, V]): seq[T] +proc `[]`[T, U: Ordinal](s: string; x: HSlice[T, U]): string first type mismatch at position: 0 -proc `[]`[T, U](s: string; x: HSlice[T, U]): string +proc `[]`[T; U, V: Ordinal](s: openArray[T]; x: HSlice[U, V]): seq[T] first type mismatch at position: 0 proc `[]`[T](s: openArray[T]; i: BackwardsIndex): T first type mismatch at position: 0 |