[JW Lua] Automatic float to integer conversion doesn't work anymore (starting in v.40/v.42)

Jan Angermüller jan at angermueller.com
Tue Nov 10 11:08:32 CET 2015


Jari,

I am trying to make my scripts compatible with v.40/v.42 and get lots of 
bad argument errors as Charles described some days ago ("Strange Error 
Message"-thread), although with different descriptions, for example:
bad argument #2 to '?' (number has no integer representation)
And in my case*these errors have not occured when running the scripts in 
previous versions of JW Lua.*

For example:
(a is an FCArticulationDef)
a.MainHandleVerticalOffset=a.MainHandleVerticalOffset+vertoffset
It used to work fine for any vertoffset value, even with vertoffset 
being a float type.
Now it throws the error message above WITHOUT the code line and requires 
an explicit integer conversion to work:
a.MainHandleVerticalOffset=a.MainHandleVerticalOffset+math.floor(vertoffset)

Although the error message is technically correct (a float is not an 
integer), the automatic type conversion used to work fine.
That will be probably be days of work to fix in more than 30.000 lines 
of code if you have to track down every error without a debugger.

What's the reason for the new error message ? Is it a stricter parser or 
Lua 5.3 or anything else ?
Do you see any chance of solving that without having to rewrite all the 
code.
Or at least add the code line when a "Bad Argument" error is thrown ?

All the best,
Jan

Am 28.10.2015 um 22:40 schrieb Charles O. Lawrence:
>
> Jari,
>
> Sometimes when running a script I get an error message like this.  
> There is no line number nor is there a red marker at any source line.  
> It makes locating the problem rather difficult in a large script.  Any 
> ideas?  Beta 0.42
>
> bad argument #2 to '?' (number expected, got boolean)
>
> Thanks,Charles
>
> Sorry, I left off the subject
>
>
>
> _______________________________________________
> JWLua mailing list
> JWLua at jwmusic.nu
> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20151110/8bc7cc0c/attachment.htm>


More information about the JWLua mailing list