<advanced>
This turn is caused is caused by the different ways in which the tables
are stored (all in the "array" part in the first case, only one element
in the "array" part in the second case). The details are quite involved
but basically #t will not change as long as you assign to indices that
exist (even if they have value nil)
$ lua
Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio
t={1,nil,nil,nil,nil,nil,nil,nil,nil,10} -- indices 1 to 10 exist in the "array part"
#t -- there is a non-nil at the highest "array part" index
10
t[5]=5 -- assigning to an existing index does not change #t
#t
10
t[12]=12 -- non-existing index triggers resizing of "array part"
#t -- [5], [10] and [12] are now in "hash part"
1
</advanced>