Incrementing "global" value with 'int++' doesn't work LSL:Luau
in progress
WolfGang Senizen
Using
LSL:Luau
when incrementing a integer declared at script level, incrementing it with int++
seems to do nothing.++int
seems to work the same across both LSL:Mono
and LSL:Luau
Reproduction steps
The following script halts in
LSL:Luau
:default {
state_entry() {
integer i;
while(i < 1) {
i++;
llOwnerSay("Ping " + (string)i);
llSleep(1.0);
}
}
}
This one does not:
integer i;
default {
state_entry() {
while(i < 1) {
i++;
llOwnerSay("Ping " + (string)i);
llSleep(1.0);
}
}
}
Log In
SuzannaLinn Resident
It seems that it fails in state_entry() only, this works:
integer i;
default {
touch_start(integer num) {
while(i < 1) {
i++;
llOwnerSay("Ping " + (string)i);
llSleep(1.0);
}
}
}
WolfGang Senizen
SuzannaLinn Resident I noticed it originally in a timer event the state entry example was mostly a minimum reproduction, interesting that it works in touch_start...
WolfGang Senizen
SuzannaLinn Resident Ok it seems that introducing a local variable fixes it, so any event that has one as a parameter will circumvent the bug. Isolating the increment to a user function brings it back
With this test setup
integer i;
check(string evnt) {
llResetTime();
test();
if(llGetTime() >= 0.5)llOwnerSay(evnt + " Fail no arg");
else llOwnerSay(evnt + " Pass no arg");
llResetTime();
testArg("test");
if(llGetTime() >= 0.5)llOwnerSay(evnt + " Fail with arg");
else llOwnerSay(evnt + " Pass with arg");
}
test() {
while(i < 1 && llGetTime() < 0.5) {
i++;
llSleep(0.1);
}
i = 0;
}
testArg(string test) {
while(i < 1 && llGetTime() < 0.5) {
i++;
llSleep(0.25);
}
i = 0;
}
default {
state_entry() {
check("state_entry");
llSetTimerEvent(0.1);
}
collision_start(integer t) {
check("collission_start");
}
touch_start(integer t) {
check("touch_start");
}
timer()
{
llSetTimerEvent(0.0);
check("timer");
}
}
They all pass the
with arg
test, but fail the no arg
test, so it's the existence of a local variable that is allowing the global increment to work.WolfGang Senizen
Harold Linden I know you've already pushed a fix, but in case there is some other edge case that this reveals to you, if you read the findings above, that SuzannaLinn Resident prompted.
H
Harold Linden
WolfGang Senizen: Yep, it strictly affects functions where you have no locals or parameters, I was incorrectly detecting the
foo = foo++
case and optimizing it into foo
for local cases even when the target register couldn't have been the source register.H
Harold Linden
marked this post as
in progress