Iterable#take tolerates null #41743
Labels
area-core-library
SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
library-collection
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
the following program
surprisingly prints (1, 2). i expected it to throw.
nothing about the take docs hint that it wouldn't throw nor what the behavior would be if given a null. the param isn't optional.
in fact, the take docs seem to hint that it would throw - it says that it's implemented as
TakeIterable<E>(this, count)
and, poking arounddart-sdk/lib/internal/iterable.dart
it seems likeTakeIterable
's constructor is supposed to throw anArgumentError
if it's given a null.i suspect that the docs are wrong and that
Iterable#take
is actually implemented asSubListIterable
, which accepts a null.but regardless of how it's implemented, it looks like a bug for
Iterable#take
to accept a null, especially considering thatTakeIterable
doesn't tolerate it.The text was updated successfully, but these errors were encountered: