#[func]
function arguments with invalid types produce weird errors
#691
Labels
c: register
Register classes, functions and other symbols to GDScript
quality-of-life
No new functionality, but improves ergonomics/internals
A function defined like this:
Produces a "missing lifetime specifier" error
Which is because the macro does
type Sig = ((), &String)
which then produces a missing lifetime error. We could instead produce an error in the macro when a reference is used in an argument's type (except for the receiver).Additionally rust-analyzer produces a "non-exhaustive pattern" error
This is because when R-A to find an implementation of the
*Signature
traits for((), &String)
it will assume theParams
associated type is((), &String)
instead of(&String,)
as intended. This leads to us trying to destruct a((), &String)
using(my_param,)
pattern.One solution could be to create a
struct Signature<Ret, Params> { .. }
type which we use instead of a pure tuple. Then the macro could explicitly set the return value and the arguments separately.For a function like this where the invalid argument isn't a reference:
The error is instead that
Vec<String>
doesn't implementToGodot
/FromGodot
as expected, however the error is displayed on thegodot_api
attribute, instead of on theVec<String>
argument type as i would expect.(the
my_param
error is the R-A error from above)The text was updated successfully, but these errors were encountered: