lua-users home
lua-l archive

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


On 21/04/14 18:00, Paige DePol wrote:
> On Apr 21, 2014, at 11:43 AM, Liam Devine <liamdevine@oolua.org> wrote:
> 
>> luac-5.3.0 -l -l -
>> local i,j,k = 1.2,2,"hello"
>> main <stdin:0,0> (4 instructions at 0x9a71b90)
>> 0+ params, 3 slots, 1 upvalue, 3 locals, 3 constants, 0 functions
>> 	1	[1]	LOADK    	0 -1	; 0
>> 	2	[1]	LOADK    	1 -2	; 0
>> 	3	[1]	LOADK    	2 -3	; "hello"
>> 	4	[1]	RETURN   	0 1
>> constants (3) for 0x9a71b90:
>> 	1	0
>> 	2	0
>> 	3	"hello"
>> locals (3) for 0x9a71b90:
>> 	0	i	4	5
>> 	1	j	4	5
>> 	2	k	4	5
>> upvalues (1) for 0x9a71b90:
>> 	0	_ENV	1	0
>>
>>
>> -- 
>> Liam
> 
> I have attached a patch which fixes this issue. It looks like someone was in the middle of changing things and somehow didn't quite finish?
> 
> The `nvalue` macro was refined in luac.c to return 0 no matter the type of number. I commented out this redefinition and then added an if/else statement in the `PrintConstant` function to use either the float or integer output format depending on the type of number.
> 
> Hopefully that will help until upstream releases work 3 (or alpha/beta?) with the official fix! :)
> 
> luac -l -l -
> local i,j,k = 1.2,2,"hello"
> ^D
> main <stdin:0,0> (4 instructions at 0x7fdb09500070)
> 0+ params, 3 slots, 1 upvalue, 3 locals, 3 constants, 0 functions
> 	1	[1]	LOADK    	0 -1	; 1.2
> 	2	[1]	LOADK    	1 -2	; 2
> 	3	[1]	LOADK    	2 -3	; "hello"
> 	4	[1]	RETURN   	0 1
> constants (3) for 0x7fdb09500070:
> 	1	1.2
> 	2	2
> 	3	"hello"
> locals (3) for 0x7fdb09500070:
> 	0	i	4	5
> 	1	j	4	5
> 	2	k	4	5
> upvalues (1) for 0x7fdb09500070:
> 	0	_ENV	1	0
> 
> 
> ~pmd~
> 

TBH I did not even look for the reason of the error, as patches are not
accepted upstream. Anyway, both nvalue and ttypenv are mentioned in the
hidden file so this is probably a known issue.
cat ./src/.fix
#define nvalue(x) ((lua_Number)0)
#define ttypenv(x) ttnov(x)

-- 
Liam

Attachment: signature.asc
Description: OpenPGP digital signature