You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to MDN, an iterator is any object that implements a next method that returns an IteratorResult (Iterator.value<'a> in RescriptCore). An iterable is any object that implements the [Symbol.iterator] method that returns an iterator.
Right now Iterator.toArray is defined as an extern using Array.from:
However, Array.from accepts an iterable, not an iterator. This means that if we implement a valid iterator (not an iterable, but an object with next), Iterator.next and Iterator.forEach will work just fine but Iterator.toArray will not: it returns an empty array.
To fix this, Iterator.toArray should be defined something like:
According to MDN, an iterator is any object that implements a
next
method that returns anIteratorResult
(Iterator.value<'a>
inRescriptCore
). An iterable is any object that implements the[Symbol.iterator]
method that returns an iterator.Right now
Iterator.toArray
is defined as an extern usingArray.from
:https://github.com/rescript-association/rescript-core/blob/22642eafb6c268c8348bd68c8569a30918b66d6b/src/Core__Iterator.res#L9C1-L9C52
However,
Array.from
accepts an iterable, not an iterator. This means that if we implement a valid iterator (not an iterable, but an object withnext
),Iterator.next
andIterator.forEach
will work just fine butIterator.toArray
will not: it returns an empty array.To fix this,
Iterator.toArray
should be defined something like:To use
Array.from
, a separate module for iterables should be defined and used instead.The text was updated successfully, but these errors were encountered: