luau-lang/luau

Test doesn't do what it says it does

Closed this issue · 2 comments

These lines say:

  -- make sure table.find checks the hash portion as well by constructing a table literal that forces the value into the hash part
  assert(table.find({[(1)] = true}, true) == 1)

The test passes, but does it really succeed in testing what it claims to? I added a C function to ltablib.cpp that will just return the arraysize of a table argument. When I then call table.size({[(1)] = true}), I get a return value of 1, indicating that the literal being created puts the entry in the array part, not in the hash part.

Perhaps in some older version of Luau, the table literal was handled in the way this test references, but this behavior is now gone, and the test was never updated?

There's a similar test in tests/conformance/basic.lua, starting around line 729.

zeux commented

Yeah this predates the table invariant. I think these will need to be adjusted to find with an offset as that's the only case when indexing with an increasing sequence can access hash part now.