diff --git a/lib/core/macros.nim b/lib/core/macros.nim index e579d6b309..6e1089b39b 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 db7cf34827..e5ef54fa45 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..