lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Fri, May 10, 2013 at 4:48 PM, Philipp Janda <siffiejoe@gmx.net> wrote:
> Am 10.05.2013 19:47 schröbte Egor Skriptunoff:
>>
>> (_G and tonumber or assert)('', '')
>>
>> bad argument #2 to 'assert' (number expected, got string)
>
>
> Am 10.05.2013 23:34 schröbte Coda Highland:
>>
>> On Fri, May 10, 2013 at 2:31 PM, Mark Gabby <mwgabby@gmail.com> wrote:
>>>
>>> Oh wait, spoke too soon. "or" is actually lower priority. Sorry. The
>>> chart
>>> in the reference manual goes from lower to higher. So I don't know.
>>
>>
>> Well, DOES _G['tonumber'] exist? If it would evaluate falsy, then that
>> WOULD return assert.
>
>
>
> `assert` would be fine with a string (or *any* value for that matter) as the
> second argument since the first argument is true-ish. So it really is
> `tonumber` throwing the error ...
>
> The problem seems to be that the debug code figuring out a name for the
> called function gets confused by `(_G and tonumber or assert)`.
>
> Error occurs in both 5.1.5 and 5.2.2.
>
> Philipp
>
>
>
>

As I was describing in another thread not that long ago, figuring out
the name of a function on the stack is hard. The debug API offers its
best guess, but it's easy to confuse it.

/s/ Adam