-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Fix expected argument count for Callable
call errors
#80844
Fix expected argument count for Callable
call errors
#80844
Conversation
368b6c2
to
0a6ecd4
Compare
From a cursory look this seems sensible, but I'm surprised that it was wrong in so many places in the codebase. Is that due to an API design change that wasn't properly propagated? |
I think Error error;
int argument;
Type expected; See also #76259. The problem is that #36368 declared |
0a6ecd4
to
a55e25b
Compare
Perhaps the first mistake was in the comment due to bad copy-paste and the following was intended: enum Error {
CALL_OK,
CALL_ERROR_INVALID_METHOD,
CALL_ERROR_INVALID_ARGUMENT, // expected is variant type
- CALL_ERROR_TOO_MANY_ARGUMENTS, // expected is number of arguments
- CALL_ERROR_TOO_FEW_ARGUMENTS, // expected is number of arguments
+ CALL_ERROR_TOO_MANY_ARGUMENTS, // argument is number of arguments
+ CALL_ERROR_TOO_FEW_ARGUMENTS, // argument is number of arguments
CALL_ERROR_INSTANCE_IS_NULL,
CALL_ERROR_METHOD_NOT_CONST,
}; Error error = Error::CALL_OK;
int argument = 0;
- int expected = 0;
+ Variant::Type expected = Variant::NIL; And then we started changing In my opinion, the original version (like in 3.x) makes more sense, since the switch (r_call_error.error) {
case Callable::CallError::CALL_ERROR_INVALID_ARGUMENT:
r_call_error.argument -= captures_amount;
// ...
break;
case Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS:
case Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS:
r_call_error.expected -= captures_amount;
// ...
break;
default:
break;
} I'm not sure if |
GDExtension has a similar struct (and the comments are even more wrong as they were capitalized :)). typedef enum {
GDEXTENSION_CALL_OK,
GDEXTENSION_CALL_ERROR_INVALID_METHOD,
GDEXTENSION_CALL_ERROR_INVALID_ARGUMENT, // Expected a different variant type.
GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS, // Expected lower number of arguments.
GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS, // Expected higher number of arguments.
GDEXTENSION_CALL_ERROR_INSTANCE_IS_NULL,
GDEXTENSION_CALL_ERROR_METHOD_NOT_CONST, // Used for const call.
} GDExtensionCallErrorType;
typedef struct {
GDExtensionCallErrorType error;
int32_t argument;
int32_t expected;
} GDExtensionCallError; If we need to change the meaning of |
a55e25b
to
aff767e
Compare
Hrm. If we wanted to make a new Am I correct in understanding that this just affects the accuracy of some error messages? If so, the worst that could happen, is that a GDExtension compiled for Godot 4.1 but opened in Godot 4.2 could generate some incorrect error messages in some cases. This could maybe just be an acceptable weirdness with using older GDExtensions? It's not a crash, and it's not an error interpreted as a success or vice-versa. We should also probably make changes similar to those in this PR to godot-cpp, so that it's using |
Here’s what this GDExtension user thinks. I say no needed, because
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR has been updated to fix the bug without breaking compat, so I think it's good to go.
Similar fixes might be needed in godot-cpp.
Thanks! |
godot/core/variant/callable.h
Lines 57 to 70 in 970be7a