lua-users home
lua-l archive

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


If I do the following in Lua 5.4:
> do
>> function Test() return 3, 5 end
>> s= string.format( "%d %d %d", 4, Test())
>> end
> s
4 3 5
... this is as expected...

> do
>> function Test() return 3, 5 end
>> s= string.format( "%d %d %d", Test(), 4)
>> end
stdin:3: bad argument #4 to 'format' (no value)
stack traceback:
        [C]: in function 'string.format'
        stdin:3: in main chunk
        [C]: in ?
... this somehow does NOT work as I would expect... (I would expect
that s now is '3 5 4')

(if I debug with breakpoint in str_format, then the top of stack ( int
top = lua_gettop(L);) is only 3 in this last case... in first case it
is 4 as expected.... .

Is this some error of Lua, or do I miss here something?