If that code is scrappy, then why the Lua documentation fully specifies the syntax of table constructors using keys that can be arbitrary expressions? For now the syntax is fully documented, since long, but it has NEVER worked reliably, never been portable, and extremely sensitive to the implementation of tables, that has changed multiple times.
It's caused by the fact that the existing implementation, while trying to optimize the storage by segregating an array part and an hashed part, has NEVER specified its own invariants. And not determining the assignment order is still a flaw, even if the table has only a single hashed part for everything.
This is a clear incoherence between what is fully documented (the syntax of table constructors can have arbitrary key _expression_ with arbitrary non-nil datatype) but the implementation has NEVER supported it correctly.