brownplt / pyret-lang

The Pyret language.
Other
1.07k stars 110 forks source link

Bug in tables#reduce #1687

Closed blerner closed 5 months ago

blerner commented 1 year ago
t = table: x, y
  row: 3, 4
  row: 9999999999999, 6
  row: 0, 8
  row: 0, 10
end

t.reduce("x", T.running-sum)

produces 3. But

extend t using x:
  sum: T.running-sum of x
end

correctly produces a much larger number.

The bug is https://github.com/brownplt/pyret-lang/blob/horizon/src/js/trove/table.js#L555 -- it both slices off the first element of the array and starts looping at index 1. It should be sufficient to eliminate the .slice(1) call.

blerner commented 8 months ago

This doesn't seem to be fixed on CPO currently.

blerner commented 8 months ago

I don't think this ever got merged -- I've created #1725 for it.