With a given Lua implementation. But the definition in the language is even worse. In Lua 5.1:

> any integer index n such that t[n] is not nil and t[n+1] is nil

So it could be 1 *or 3*.

In Lua 5.2 it is even clearer:

> Unless a __len metamethod is given, the length of a table t is only defined if the table is a sequence, that is, the set of its positive numeric keys is equal to {1..n} for some integer n

So the operator could return *anything*. Or crash your program, for that matter. Actually I expect some later Lua implementations to return an error in that situation.

Anyway, my point is: you cannot rely on it being 3 but you cannot rely on it being 1 either.