Skip to content

Conversation

@Yarwin
Copy link
Contributor

@Yarwin Yarwin commented Oct 25, 2025

closes: #1374

Before this PR, following code:

#[derive(GodotClass)]
#[class(init, base = Node)]
struct MyClass {
    base: Base<Node>,
}

#[godot_api]
impl INode for MyClass {
    #[func(gd_self)]
    fn physics_process(_this: Gd<Self>) {

    }

    #[func(gd_self)]
    fn process(_this: Gd<Self>, _delta: i32) {}
}

did compile without issues, now it throws following errors:

error[E0308]: mismatched types
  --> src/lib.rs:19:5
   |
16 | #[godot_api]
   | ------------ expected due to this
...
19 |     fn physics_process(_this: Gd<Self>) {
   |     ^^ expected `(f64,)`, found `()`
   |
   = note:  expected tuple `(f64,)`
           found unit type `()`

error[E0308]: mismatched types
  --> src/lib.rs:24:5
   |
16 | #[godot_api]
   | ------------ expected due to this
...
24 |     fn process(_this: Gd<Self>, _delta: i32) {}
   |     ^^ expected `(f64,)`, found `(i32,)`
   |
   = note: expected tuple `(f64,)`
              found tuple `(i32,)`

error[E0308]: mismatched types
  --> src/lib.rs:16:1
   |
16 |   #[godot_api]
   |   ^^^^^^^^^^^^ expected `i32`, found `f64`
17 |   impl INode for MyClass {
   |  ________________-
18 | |     #[func(gd_self)]
19 | |     fn physics_process(_this: Gd<Self>) {
...  |
23 | |     #[func(gd_self)]
24 | |     fn process(_this: Gd<Self>, _delta: i32) {}
   | |______________- arguments to this function are incorrect
   |
note: associated function defined here
  --> src/lib.rs:24:8
   |
24 |     fn process(_this: Gd<Self>, _delta: i32) {}
   |        ^^^^^^^                  -----------
   = note: this error originates in the attribute macro `godot_api` (in Nightly builds, run with -Z macro-backtrace for more info)

@Yarwin Yarwin added bug c: register Register classes, functions and other symbols to GDScript labels Oct 25, 2025
@Yarwin Yarwin force-pushed the bugfix/validate-call-params-for-gd-self-methods branch from 0f16afe to 0102c26 Compare October 25, 2025 06:17
@GodotRust
Copy link

API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-1382

@Yarwin Yarwin force-pushed the bugfix/validate-call-params-for-gd-self-methods branch from 0102c26 to a88358e Compare October 25, 2025 06:37
Copy link
Member

@Bromeon Bromeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!

/// For example `::godot::private::virtuals::Node::Sig_physics_process` is `(f64, )`,
/// thus `let params: ::godot::private::virtuals::Node::Sig_physics_process = ();`
/// will not compile.
fn make_tuple_sig_annotation(trait_base_class: &Ident, method_name: &Ident) -> TokenStream {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fn make_tuple_sig_annotation(trait_base_class: &Ident, method_name: &Ident) -> TokenStream {
fn make_sig_tuple_annotation(trait_base_class: &Ident, method_name: &Ident) -> TokenStream {

To be consistent with variable name.

@Yarwin Yarwin force-pushed the bugfix/validate-call-params-for-gd-self-methods branch from a88358e to 81dfc9a Compare October 25, 2025 09:18
@Bromeon Bromeon added this pull request to the merge queue Oct 25, 2025
Merged via the queue into godot-rust:master with commit 8ad4daf Oct 25, 2025
17 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug c: register Register classes, functions and other symbols to GDScript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parameters in virtual #[func(gd_self)] are not validated

3 participants