iterators: several small fixes (#11162)

* fix pairs, mpairs, mitems for cstring for JS backend
* add mutation check for pairs and mpairs for strings and seqs
* change the assertion message - modifying (changing elements) is not
  a problem, changing the length is
This commit is contained in:
Miran 2019-05-04 23:02:50 +02:00 • committed by Andreas Rumpf
commit ce152ed91f
3 changed files with 53 additions and 26 deletions

View file

@ -6,7 +6,7 @@ iterator myitems*[T](a: var seq[T]): var T {.inline.} =
while i < L:
yield a[i]
inc(i)
assert(len(a) == L, "seq modified while iterating over it")
assert(len(a) == L, "the length of the seq changed while iterating over it")
# Works fine
var xs = @[1,2,3]