[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: incorrect "error" signaled by type(value), when the argument value is nil
- From: Bas Groothedde <lua@...>
- Date: Mon, 6 Sep 2021 18:44:16 +0200
> And the builtin `string.byte(index)` function SHOULD also be fixed to return a true `nil` for a given index past the end of string, and not an empty list (or this should not make any difference for calling type()).
string.byte can return multiple values depending on the i and j arguments, meaning that it dynamically returns values. If there are no values to return, string.byte signals Lua that it has placed 0 values on the stack upon return.
type requires any value, so not LUA_TNONE. The fact that "none" gets coerced to "nil" upon assignment (because otherwise the assignment breaks), doesn't really mean that a call like you describe should work in my honest opinion.
I may misunderstand, however that's how I've always seen it.
~b