Restore numeric from String constructors
Closes #44407
Lots of CI build errors along those lines:
core/variant/variant_construct.h: In static member function 'static void VariantConstructorFromString<T>::ptr_construct(void*, const void**) [with T = long int]':
core/variant/variant_construct.h:258:11: error: 'dst_var' may be used uninitialized in this function [-Werror=maybe-uninitialized]
258 | Variant type_test = Variant(dst_var);
| ^~~~~~~~~
core/variant/variant_construct.h: In static member function 'static void VariantConstructorFromString<T>::ptr_construct(void*, const void**) [with T = double]':
core/variant/variant_construct.h:258:11: error: 'dst_var' may be used uninitialized in this function [-Werror=maybe-uninitialized]
258 | Variant type_test = Variant(dst_var);
| ^~~~~~~~~
I guess GetTypeInfo<T>::VARIANT_TYPE can be used instead of dummy Variants.
I am not happy with this kind of automatic cast, as it an be quite prone to errors. We discussed with @vnen at that point in time and believed it would be better you use the str() function instead in GDScript.
But the PR is about int("string"). It no longer works in 4.0.
I don't know how it works internally; if it causes implicit conversions then I agree it's bad :/
I checked and this
var a: int
a = "123"
does not work, so I guess it's fine? 🤔
To me this looks completely fine. Reduz may have gotten confused. I tried myself, and no implicit conversion is done. There may be other circumstances where it is, however?
Thanks!