Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

New compiler bug: more conditional problems.

Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
06-27-2004 20:54
It turns out conditional statements in a function cause more problems with functions then initially expected.
CODE
string myFunc() {
if (TRUE) {
return;
}
return "Foo";
}


This code snippet compiles perfectly. When the function is supposed to return a string or list, and hits that "return;", the runtime throws a Bounds Check Error. If the return type is not a string or list, it will return the "zero" value of the type. (0, 0.0, ZERO_VECTOR, ZERO_ROTATION, etc). This same bug allows you to change state within a function, so its a good candidate for debate.

Bug report submitted! I just wanted to notify everyone about this, Bounds Check Errors are ugly beasts, totally difficult to debug unless you difinitively know what is causing it.
==Chris
Francis Chung
This sentence no verb.
Join date: 22 Sep 2003
Posts: 918
06-28-2004 05:21
Is this valid LSL? You are returning without specifying a return value.

I think this might be valid, but undefined LSL.

To draw an analogy:
In C/C++/Java, it is legal to say i = i++, but the result is undefined.
_____________________
--
~If you lived here, you would be home by now~
Azelda Garcia
Azelda Garcia
Join date: 3 Nov 2003
Posts: 819
06-28-2004 06:00
Yeah, but the point is: it shouldnt compile.

Azelda

P.S. Looking for someone to write a server-side scripting engine.
Rhysling Greenacre
Registered User
Join date: 15 Nov 2003
Posts: 132
06-28-2004 10:15
It's valid Ruby, but I digress!
Sitting Lightcloud
Registered User
Join date: 13 May 2004
Posts: 109
09-01-2004 17:53
When I tried to compile without returning anything in the foo() below I got this error.

Error: Function returns a a value but return statement doesn't

The code below compiles but gives
Object: Script run-time error
Object: Bounds Check Error
As it should but earlier I don't think it would compile...
Just incase someone else have this problem....

CODE

init()
{
foo();
}

string foo(integer i)
{
return "";
}

default
{
state_entry()
{
init();
}

}

Siro Mfume
XD
Join date: 5 Aug 2004
Posts: 747
09-01-2004 19:19
From: someone
Originally posted by Sitting Lightcloud
When I tried to compile without returning anything in the foo() below I got this error.

Error: Function returns a a value but return statement doesn't

The code below compiles but gives
Object: Script run-time error
Object: Bounds Check Error
As it should but earlier I don't think it would compile...
Just incase someone else have this problem....

CODE

init()
{
foo();
}

string foo(integer i)
{
return "";
}

default
{
state_entry()
{
init();
}

}



in this case shouldn't you be defining the function foo before the function init() since it calls foo before it's defined kinda? I had thought I had read something about that earlier...
Sitting Lightcloud
Registered User
Join date: 13 May 2004
Posts: 109
09-01-2004 20:43
Yes, I should but before it wouldn't compile, yesterday it did AND WORKED! and today it crashed :D Just wanted to share if someone else was having the Bounds Check Error wich I never seen before...