Skip to content

Better errors when the signature of exported methods are invalid #439

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

Closed
Tracked by #767
ghost opened this issue Jun 21, 2020 · 1 comment · Fixed by #975
Closed
Tracked by #767

Better errors when the signature of exported methods are invalid #439

ghost opened this issue Jun 21, 2020 · 1 comment · Fixed by #975
Assignees
Labels
c: export Component: export (mod export, derive) feature Adds functionality to the library
Milestone

Comments

@ghost
Copy link

ghost commented Jun 21, 2020

Currently, all errors originating from the signatures of exported methods are spanned at the #[gdnative::methods] attribute. This makes it tricky to find the errors in cases where:

  • The owner type is wrong (or maybe missing?)
  • An argument type isn't FromVariant.

Currently, the errors look like:

error[E0308]: mismatched types
  --> examples/dodge_the_creeps/src/hud.rs:11:1
   |
11 | #[methods]
   | ^^^^^^^^^^ expected struct `gdnative::gdnative_bindings::CanvasLayer`, found `&gdnative::gdnative_bindings::CanvasLayer`
   |
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `gdnative::gdnative_bindings::PhysicsBody2D: gdnative::FromVariant` is not satisfied
  --> examples/dodge_the_creeps/src/player.rs:17:1
   |
17 | #[methods]
   | ^^^^^^^^^^ the trait `gdnative::FromVariant` is not implemented for `gdnative::gdnative_bindings::PhysicsBody2D`
   |
   = note: required by `gdnative::FromVariant::from_variant`
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

We might have to reimplement godot_wrap_method as procedural macro for the errors to be properly spanned.

@ghost ghost added feature Adds functionality to the library c: export Component: export (mod export, derive) labels Jun 21, 2020
@karroffel karroffel self-assigned this Jun 21, 2020
@ghost
Copy link
Author

ghost commented Jun 24, 2020

This is partially improved in #443 and the errors point at individual method names now. It's still not ideal, but is a big improvement over the original situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: export Component: export (mod export, derive) feature Adds functionality to the library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants