-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
Integer is zero when passing it to function that takes f32/f64 #105
Comments
Here is some more info about my system/environment:
|
I think conversions from GDScript In ergonomics sake, we can maybe define some rules regarding which conversions are safe. Anyway, thanks for reporting! |
So i think this issue is at least partially fixed. i.e when done as a ptrcall it will succeed as expected, however when done as a varcall this will report a spurious error that the method does not exist for the second call. this is caused (i believe) by us panicking when we try to convert a variant containing |
@thebigG do you know if this is still a problem with latest master and latest Godot (4.2-rc1)? |
Current status of this, running this code: var bar: Bar = $Bar
bar.add_two(1.0)
bar.add_two(1)
$Bar.add_two(1.0)
$Bar.add_two(1) will print for consistency we should probably try to make it so that 2 and 4 have the same behavior. either both have a type conversion error or they both succeed with type coercion. |
var bar: Bar = $Bar # Rust receives:
bar.add_two(1.0) # 1) 1.0
bar.add_two(1) # 2) 1.0
$Bar.add_two(1.0) # 3) 1.0
$Bar.add_two(1) # 4) ERROR I looked further into this. We can't change the first two, because they use ptrcalls and Rust only receives the already correctly typed value. 3) and 4) are varcalls, and 4) currently fails due to variant conversions being forbidden between
Another option would be to have a separate set of conversions, like gdnative's Apart from that, GDScript provides a strict typing mode, but I'm not sure if this just requires type annotations or also prevents implicit conversions. But I don't think beyond that we can influence the behavior of 1) and 2). |
See also: #845 (comment) So, Godot has two functions that check conversions between different
Both are directly available in the GDExtension C API. Our current Rust implementation for To have varcalls behave exactly like ptrcalls from GDScript perspective, I see no alternative than downgrading to "Godot strict" semantics. While it allows more harmless things like In other words, this has the ironic effect that not using types in GDScript is actually more type-safe 😬 * It needs to be confirmed whether GDScript-side implicit conversions before ptrcalls indeed use the same semantics as |
Hi there,
I defined the following function in my gdextension:
The following call has no problems from gdscript
This will print
a:1
, which is expected.However if I call this
This prints
a:0
, which is not what I expected.Is this behavior expected, or is there something else going here I'm missing?
My mind went directly to ABI--I thought for some reason something the rust compiler is doing...?
In any case I looked at the dwarf and it looks like the type abi from my rust gdextension matches that of Godot functions "real_t".
Here is
real_t
dwarf info from godot compiled from source:Here is the one for my rust code
I hope I explained this clearly enough. Am I missing something here?
Thanks in advance!
The text was updated successfully, but these errors were encountered: