Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0003822opensim[REGION] Scripting Enginepublic2009-06-20 12:512011-07-30 05:47
Reportercrystalsgalicia 
Assigned To 
PrioritynormalSeveritytweakReproducibilityalways
StatusconfirmedResolutionopen 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0003822: Passing a bool as an integer in a LSL2 script without typecasting to integer results in compile error
DescriptionConsider the following line:

llSetAlpha((llDetectedKey(0)==llGetOwner()),ALL_SIDES);

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);
TagsNo tags attached.
Git Revision or version number
Run ModeStandalone (1 Region) , Standalone (Multiple Regions) , Grid (1 Region per Sim) , Grid (Multiple Regions per Sim)
Physics Engine
Script Engine
EnvironmentUnknown
Mono VersionNone
Viewer
Attached Files

- Relationships

-  Notes
(0012201)
melanie (administrator)
2009-06-20 12:54

This is a known issue, but not easy to solve.
(0012202)
crystalsgalicia (reporter)
2009-06-20 14:04

Melanie: Can you elaborate a bit? I can't imagine it would be more difficult than catching the error and casting it there.
(0012204)
melanie (administrator)
2009-06-21 04:57

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.
(0012208)
HomerHorwitz (manager)
2009-06-21 10:12

Hm, shouldn't using LSLTypes for LSL functions (LSLTypes.Float in that case) fix that automatically?
(0012209)
melanie (administrator)
2009-06-21 10:15

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....
(0012245)
crystalsgalicia (reporter)
2009-06-22 08:00

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.
(0012246)
melanie (administrator)
2009-06-22 11:36

Parsing the expression and adding the cast is the preferred solution. However, as I said, it requires a type-aware parser.
(0019223)
makopoppo (manager)
2011-07-30 05:47

It is still an issue in OpenSim 0.7.2-dev. But I don't know if it should be fixed...

- Issue History
Date Modified Username Field Change
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
Powered by Mantis Bugtracker