Open Hixie opened 7 years ago
There are better RangeError
versions too.
I'm making the VM use RangeError.checkValidRange and dart2js do better errors too (and some flow optimization while I'm there).
Similar problem with double.clamp()
. I had accidentally given it double.INFINITY for the first argument (instead of -double.INFINITY) and it just told me that wasn't a valid value, not that the lower bound was greater than the upper bound, which would have been much more helpful.
When the start index is greater than the end index, we throw a RangeError with the start index as the value that's flagged as bad. This leads to an error like "RangeError: Value not in range: 97".
This is confusing because the start index is fine, what's wrong is the relationship between the start and end indices. (Typically this will happen when the developer thinks the second argument is a length, rather than an end index.)
IMHO we should through a more elaborate ArgumentError here rather than a RangeError.