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
I found that the module_Variant method for the String type in GDExtension did not return the correct result. They all returned an incorrect result <null>. Could this be a bug? I haven't found any posts mentioning a similar issue.
Steps to reproduce
I tried the following code. The output on the left is correct, while the result on the right is incorrect.
So, I had to resort to the most cumbersome way, using a switch statement to solve the issue where the Variant type couldn't be handled correctly.
switch (p_value.get_type())
{
case Variant::NIL:
s = str % nullptr;
break;
case Variant::BOOL:
s = str % bool(p_value);
break;
case Variant::INT:
s = str % int64_t(p_value);
break;
case Variant::FLOAT:
s = str % double(p_value);
break;
.....
.....
.....
case Variant::PACKED_COLOR_ARRAY:
s = str % PackedColorArray(p_value);
break;
case Variant::PACKED_VECTOR4_ARRAY:
s = str % PackedVector4Array(p_value);
break;
default:
s = str % p_value;
break;
}
Minimal reproduction project (MRP)
1
The text was updated successfully, but these errors were encountered:
akien-mga
changed the title
[gdextension]I found a bug when use the String module operator for Variant type.
Bug when using the String module operator for Variant type.
Sep 24, 2024
I'm really surprised to learn we have these operator%(...) methods in godot-cpp!
Since this isn't supported in Godot itself, having them goes against one of godot-cpp design goals, which is to support the same API as Godot. I think it might be better to remove these operators, rather than fix them. We appear to be automatically generating them based on the extension_api.json, so it'd be a matter of filtering them out in binding_generator.py.
Using vformat() would be the recommended way to do this kind of string formatting in godot-cpp
Tested versions
System information
Windows 11
Issue description
I found that the
module_Variant
method for theString
type in GDExtension did not return the correct result. They all returned an incorrect result<null>
. Could this be a bug? I haven't found any posts mentioning a similar issue.Steps to reproduce
I tried the following code. The output on the left is correct, while the result on the right is incorrect.
They each used different overloaded operators, as shown below.
source_code
So, I had to resort to the most cumbersome way, using a
switch
statement to solve the issue where theVariant
type couldn't be handled correctly.Minimal reproduction project (MRP)
1
The text was updated successfully, but these errors were encountered: