Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005324opensim[REGION] Scripting Enginepublic2011-01-12 13:052019-02-25 10:13
Assigned To 
PlatformOSOS Version
Product Versionmaster (dev code) 
Target VersionFixed in Version 
Summary0005324: brackets should not be necessary around if ... else clause
DescriptionThe following script compiles fine in SL but not in opensim :
        if (1 == 1)
            if (2 == 2) llSay(0, "a");
            else llSay(0, "b");
        else llSay(0, "c");
Additional InformationWith OpenSim 0.6.9, it produces following error:

Error CS1002: ; expected

With opensim 0.7.1 Dev, it produces following error:

else expected

The workaround is obvious, but still it's an incompatibility with Linden Lab scripting language
TagsNo tags attached.
Git Revision or version number;-)
Run Mode Grid (Multiple Regions per Sim)
Physics EngineBasicPhysics
Script Engine
EnvironmentMono / Linux32, Mono / Windows
Mono VersionNone
ViewerHippo + imprudence
Attached Files

- Relationships

-  Notes
tampa (reporter)
2019-02-25 07:15

So can confirm it does not compile, placing the error marker in the first else. However I believe the issue here is actually that the first if has two lines, which seems to break the convention of "if only has one line". Removing the first else twig makes it compile.

It is interesting to see that using following script the return is c

integer a = 0;
integer b = 1;
        if (b == 1)
            if (a == 1) llSay(0, "a");
        else llSay(0, "c");

Which means it does not nest the if under the first. That means the else is attached to the second if, not the first.

What is the actual philosophy here, how do other languages behave and is there documentation on this behavior or caveat for SL?
UbitUmarov (administrator)
2019-02-25 09:34
edited on: 2019-02-25 09:47

tampa example is a reason why one should always use {} on if else blocks and not rely on compilers to figure it out, in fact we can't even understand that code without thinking.
In that case they must refer to previous (second) if so that reads

        if (b == 1)
            if (a == 1) llSay(0, "a");
            else llSay(0, "c");

tampa (reporter)
2019-02-25 10:13

I agree that using brackets is always better for clarity. Though with the lack of switchcase one may wish to use single line if without them.

I only tested on XEngine, you said it works fine one YEngine, so question would be whether it is worth fixing on XEngine.

- Issue History
Date Modified Username Field Change
2011-01-12 13:05 aime New Issue
2011-01-12 13:05 aime Git Revision => ;-)
2011-01-12 13:05 aime SVN Revision => 0
2011-01-12 13:05 aime Run Mode => Grid (Multiple Regions per Sim)
2011-01-12 13:05 aime Physics Engine => BasicPhysics
2011-01-12 13:05 aime Environment => Mono / Linux32, Mono / Windows
2011-01-12 13:05 aime Mono Version => None
2011-01-12 13:05 aime Viewer => Hippo + imprudence
2019-02-25 07:15 tampa Note Added: 0034847
2019-02-25 07:15 tampa Status new => confirmed
2019-02-25 09:34 UbitUmarov Note Added: 0034854
2019-02-25 09:47 UbitUmarov Note Edited: 0034854 View Revisions
2019-02-25 10:13 tampa Note Added: 0034855

Copyright © 2000 - 2012 MantisBT Group
Powered by Mantis Bugtracker