|Anonymous | Login | Signup for a new account||2020-01-23 12:53 PST|
|Main | My View | View Issues | Change Log | Roadmap | Summary | My Account|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0003822||opensim||[REGION] Scripting Engine||public||2009-06-20 12:51||2011-07-30 05:47|
|Target Version||Fixed in Version|
|Summary||0003822: Passing a bool as an integer in a LSL2 script without typecasting to integer results in compile error|
|Description||Consider the following line:|
In SecondLife's original LSL2 engine and Mono, the result of the == operation would be passively typecasted into an integer (or, as the case may be, float), since the boolean type doesn't exist in LSL2 anyway.
In an OpenSim, you get a compile error saying that the bool couldn't be converted to a double (in this example).
Desired behavior: Passively typecast a boolean to an integer or float if passed to a function expecting an integer or float in an LSL script.
The following workaround fixes it (typecast manually): llSetAlpha((integer)(llDetectedKey(0)==llGetOwner()),ALL_SIDES);
|Tags||No tags attached.|
|Git Revision or version number|
|Run Mode||Standalone (1 Region) , Standalone (Multiple Regions) , Grid (1 Region per Sim) , Grid (Multiple Regions per Sim)|
|This is a known issue, but not easy to solve.|
|Melanie: Can you elaborate a bit? I can't imagine it would be more difficult than catching the error and casting it there.|
|Unfortunately, it can't be done that way. The parser has to be modified to insert casts as needed. Since our parser is currently not type-aware, this would be a useful, but major, change.|
|Hm, shouldn't using LSLTypes for LSL functions (LSLTypes.Float in that case) fix that automatically?|
|No, because the == operator always returns bool. So, even an override returns bool. In simple lagnuage constructs,, where such a bool is passed to methods taking LSLInteger, LSLInteger can perform that cast. However, while an expression is evaluated, we have no control at all. I think LL may have user their expression parser from LSO days to make Mono LSL 100% compatible. We don't really want to write a new expression parser....|
I might be speaking out of line because I don't know this programming language very well (and I've never seen the source anyway), but surely you can do something simple and patch-like.
For example, this ugly little logic; If you find an expression in the line, add the (integer) or (float) typecast to the beginning of the expression during the parsing only. Or, if this language has error handling like VB/VC#.net have (and I'm pretty darn sure it does because you /are/ reporting the error correctly), just see if the error is this particular error and manually change the return to an integer or float during the error handling rather than crashing.
Or, if nothing else, take the approach you took with the list memory hack; be more specific, just tell the scripter that they have to typecast that evaluation manually.
|Parsing the expression and adding the cast is the preferred solution. However, as I said, it requires a type-aware parser.|
|It is still an issue in OpenSim 0.7.2-dev. But I don't know if it should be fixed...|
|2009-06-20 12:51||crystalsgalicia||New Issue|
|2009-06-20 12:51||crystalsgalicia||SVN Revision||=> 0|
|2009-06-20 12:51||crystalsgalicia||Run Mode||=> Standalone (1 Region) , Standalone (Multiple Regions) , Grid (1 Region per Sim) , Grid (Multiple Regions per Sim)|
|2009-06-20 12:51||crystalsgalicia||Environment||=> Unknown|
|2009-06-20 12:51||crystalsgalicia||Mono Version||=> None|
|2009-06-20 12:54||melanie||Note Added: 0012201|
|2009-06-20 14:04||crystalsgalicia||Note Added: 0012202|
|2009-06-21 04:57||melanie||Note Added: 0012204|
|2009-06-21 10:12||HomerHorwitz||Note Added: 0012208|
|2009-06-21 10:15||melanie||Note Added: 0012209|
|2009-06-22 08:00||crystalsgalicia||Note Added: 0012245|
|2009-06-22 11:36||melanie||Note Added: 0012246|
|2011-07-30 05:47||makopoppo||Note Added: 0019223|
|2011-07-30 05:47||makopoppo||Status||new => confirmed|
|Copyright © 2000 - 2012 MantisBT Group|