Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lerp accepts Variant as a weight, should be float #96528

Open
aXu-AP opened this issue Sep 3, 2024 · 4 comments
Open

lerp accepts Variant as a weight, should be float #96528

aXu-AP opened this issue Sep 3, 2024 · 4 comments

Comments

@aXu-AP
Copy link
Contributor

aXu-AP commented Sep 3, 2024

Tested versions

Reproducible in v4.3.stable.official [77dcf97] or any 4.x

System information

Windows 11

Issue description

lerp accepts any Variant as a weight, altough it only supports float. Giving other values causes the function to fail silently. This problem was mentioned in #64332 as well, but I think it is a separate issue.
kuva

The function is registered with a macro FUNCBINDVR3, which doesn't offer flexibility around the argument types. Possible solutions: inline the contents of the macro and write correct get_argument_type(int p_arg) function. Or modify the macro to relay the correct argument types.

Steps to reproduce

Write

lerp(0.0, 10.0, "hello")

or just see the reference...

Minimal reproduction project (MRP)

N/A

@AThousandShips
Copy link
Member

This is a limitation of the bind system I think, as the method is defined with double as the third argument

@aXu-AP
Copy link
Contributor Author

aXu-AP commented Sep 3, 2024

The binding system works as it should, but the macro generates incorrect code for this function. I tested the solution I suggested:

inline the contents of the macro and write correct get_argument_type(int p_arg) function.

And it works. But is it a wanted solution? Macros exists for a reason...

@AThousandShips
Copy link
Member

It generates the designed code, but doesn't consider mixed argument specificity, and the macros ensure things aren't accentially missed, so inlining it would be potentially error prone

But this would need to be tested and discussed more generally, especially since it still would break compatibility, and we can't fix compatibility in these methods so that will mess with extensions

@OffsetMOSFET
Copy link

OffsetMOSFET commented Sep 5, 2024

One quirk of this: You can set the weight to a String of a float.

print(lerp(1, 10, 0.5)) # -> 5.5
print(lerp(1, 10, "0.5")) # -> 5.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants