-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Improve error message when trying to call non-@tool
function from @tool
script
#84045
Improve error message when trying to call non-@tool
function from @tool
script
#84045
Conversation
The comments in the code say "is likely", but the actual message to the user speaks as a matter of fact. Is it guaranteed to be that case? The comment shouldn't say "is likely" then. Is it not guaranteed to be that case? The user to the message should say "it may be" or maybe the message should just be "$STANDARD_MESSAGE (function is not in @tool script?)", mimic'ing question-mark "?" bugs for other compilers that theorize what the issue is to the user ("Missing semi-colon?"). |
6cea41d
to
4bc4ac4
Compare
err_text = _get_call_error(err, "function '" + methodstr + (is_callable ? "" : "' in base '" + basestr) + "'", (const Variant **)argptrs); | ||
|
||
String tool_suffix; | ||
if (base->has_method(methodstr)) { |
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.
I think this is too broad, maybe:
if (base->has_method(methodstr)) { | |
if (err.error == Callable::CallError::CALL_ERROR_INVALID_METHOD && base->has_method(methodstr)) { |
Same below
This part can be reached with other errors, not just not found, like invalid arguments, see for example this output from CI:
Invalid type in function 'expect_typed' in base 'RefCounted (typed_array_pass_basic_to_typed.gd)' ('expect_typed' is from a non-
@tool
script, but is called from@tool
script; make the script containing 'expect_typed'@tool
). The array of argument 1 (Array) does not have the same element type as the expected typed array argument.
Also same about the methodstr
:
methodstr = String(*argptrs[0]) + " (via TreeItem.call_recursive)";
methodstr = base->operator String() + " (Callable)";
methodstr = String(*argptrs[0]) + " (via call)";
So some more sensitive checking needs to be done IMO
err_text = _get_call_error(err, "function '" + methodstr + "' in base '" + basestr + "'", (const Variant **)argptrs); | ||
|
||
String tool_suffix; | ||
if (base->has_method(methodstr)) { |
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.
This won't work if it's via call
, see above:
methodstr = String(*argptrs[0]) + " (via call)";
Testing project: test_tool_script_function_error.zip
Preview
Before
After