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
{{ message }}
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.
Range values are comparable: two range values compare equal if they denote the same sequence of integers, even if they were created using different parameters.
The interpreter contains a bug: range(0, 5, 10) == range(0, 5, 11) returns False.
Bazel, Python2, and Python3 return True (Bazel's implementation is not necessarily the best, as it iterates over the values).
The text was updated successfully, but these errors were encountered:
Well spotted! The fix is that we should only compare the step if len > 1.
func rangeEqual(x, y rangeValue) bool {
// Two ranges compare equal if they denote the same sequence.
if x.len != y.len {
return false // sequences differ in length
}
if x.len == 0 {
return true // both sequences are empty
}
if x.start != y.start {
return false // first element differs
}
return x.len == 1 || x.step == y.step
}
testdata/builtins.star
+assert.eq(range(0, 5, 10), range(0, 5, 11))
I won't fix it just yet because I'm hoping to cut over to the new repo any day now.
alandonovan
pushed a commit
to google/starlark-go
that referenced
this issue
Nov 2, 2018
According to the specification:
The interpreter contains a bug:
range(0, 5, 10) == range(0, 5, 11)
returnsFalse
.Bazel, Python2, and Python3 return
True
(Bazel's implementation is not necessarily the best, as it iterates over the values).The text was updated successfully, but these errors were encountered: