You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code is below. This is the output, with the error included.
When before is true, arg1 is the sub-array. When false, arg1 switches to become the float. I'm not sure if this is intended or not, but it feels like a bug.
When before is true
arg1:[2, 2]
arg2:1.1
arg1:[3, 2.5]
arg2:1.1
4
When before is false
arg1:1.1
arg2:[2, 2]
Invalid access to property or key '1' on a base object of type 'float'.
PS - Can anyone explain what before is supposed to do anyway? The docs need an example.
Steps to reproduce
extendsNode2Dfunc_ready() ->void:
test()
functest():
# "The custom method receives two arguments (an element from the array and the value searched for)"varcmp=func(arg1,arg2): print("arg1:",arg1); print("arg2:", arg2);returnarg1[1]>=arg2varX:=[ [0, 1.0], [1, 1.5], [2, 2.0], [3, 2.5] ]
print("When before is true")
varindex=X.bsearch_custom( 1.1, cmp, true )
print(index)
print()
print("When before is false")
# We get an error:# Invalid access to property or key '1' on a base object of type 'float'.# Because the arguments to `cmp` have swapped!index=X.bsearch_custom( 1.1, cmp, false )
print(index)
You can't assume the order of the comparison, this isn't an error, the comparison function is supposed to take both types, though the fact it can take both orders might be made clear though it never says it is in the order you expected:
The custom method receives two arguments (an element from the array and the value searched for) and must return true if the first argument is less than the second, and return false otherwise.
Tested versions
v4.3.dev.custom_build [9f4499c]
System information
Godot v4.3.dev (9f4499c) - Ubuntu 22.04.4 LTS 22.04 - X11 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2060 (nvidia; 535.161.07) - Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz (6 Threads)
Issue description
The code is below. This is the output, with the error included.
When before is true,
arg1
is the sub-array. When false,arg1
switches to become the float. I'm not sure if this is intended or not, but it feels like a bug.PS - Can anyone explain what
before
is supposed to do anyway? The docs need an example.Steps to reproduce
Minimal reproduction project (MRP)
https://gitlab.com/dbat/array_bsearch_issue
The text was updated successfully, but these errors were encountered: