check input ranges in rest-unique-range-values

the ranges passed into restricted_unique_range_values could potentially
be invalid which can lead to unexpected results. this commit adds sanity
checks at the beginning of the call to make sure this does not happen.