Open jbclements opened 4 months ago
Sorry, I should add: I also added a test that no longer fails.
@jbclements - thanks for this. I'll look it over. Regardless, nice find. Gotta love edge cases. :wink:
I've fixed this differently in caf938a. I've added a table-index-size
function (unexposed right now) and bumped the version.
Thanks again!
Ah... correct. The fix is good, just the test is wrong.
(test-case "Add column to table with columns and no rows"
(let ([zero-rows-table (table-with-column empty-table '() #:as 'a)])
(check-table (table-with-column zero-rows-table '(1 2 3) #:as 'b)
'(a b)
'())))
Would you agree this test reflects the fix?
The existing code appears to have a bug that prevents adding a column to a table with columns but no rows. Specifically, it uses argmax on the index vector to determine the size of the new vector, but for tables with columns but no rows, this index vector is empty, and argmax signals an error. To solve this, I special-case the empty vector and return zero as the length of the new vector.