llListFindListNext returns incorrect value for last list element
tracked
Wulfie Reanimator
llListFindListNext(haystack, needle, instance);
Returns the index for the Nth
instance
of needle
. instance
is zero-based.Returns -1 when there aren't enough instances.
Error: Returns
last index + 1
when needle
is the last element of the list.integer index;
list haystack = ["A", "B", "C"];
index = llListFindListNext(haystack, ["C"], 0); // OK
llSay(PUBLIC_CHANNEL, "Expect 2: " + (string)index);
index = llListFindListNext(haystack, ["B"], 1); // OK
llSay(PUBLIC_CHANNEL, "Expect -1: " + (string)index);
index = llListFindListNext(haystack, ["C"], 1);
llSay(PUBLIC_CHANNEL, "Expect -1: " + (string)index);
index = llListFindListNext(haystack, ["C"], 23);
llSay(PUBLIC_CHANNEL, "Expect -1: " + (string)index);
Log In
Monty Brandenberg
The challenge now is that this has likely been wrong since... 2023? Thinking about measures scripters have taken to work around this and the possible impact of correcting it. Will we break workflows or will those measures simply be harmless under a working API implementation? Probably the latter...
JenniWindrider Resident
Considering this bug is now about a year old... any news, Maestro Linden?
Maestro Linden
marked this post as
tracked
Maestro Linden
Hi Wulfie, thanks for the helpful report with repro script. Testing on Second Life Server 2025-03-14.13862207703, I see that 3rd and 4th test cases return 3. I agree with your assessment that those test cases should return -1.