1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Add error for undefined function in shader

This commit is contained in:
MoltenCoffee
2023-07-14 11:36:48 +02:00
parent 60f3b7967c
commit 16c3f4be2d

View File

@@ -3388,12 +3388,14 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI
} }
int last_arg_count = 0; int last_arg_count = 0;
bool exists = false;
String arg_list = ""; String arg_list = "";
for (int i = 0; i < shader->functions.size(); i++) { for (int i = 0; i < shader->functions.size(); i++) {
if (name != shader->functions[i].name) { if (name != shader->functions[i].name) {
continue; continue;
} }
exists = true;
if (!shader->functions[i].callable) { if (!shader->functions[i].callable) {
_set_error(vformat(RTR("Function '%s' can't be called from source code."), String(name))); _set_error(vformat(RTR("Function '%s' can't be called from source code."), String(name)));
@@ -3494,10 +3496,12 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI
} }
} }
if (last_arg_count > args.size()) { if (exists) {
_set_error(vformat(RTR("Too few arguments for \"%s(%s)\" call. Expected at least %d but received %d."), String(name), arg_list, last_arg_count, args.size())); if (last_arg_count > args.size()) {
} else if (last_arg_count < args.size()) { _set_error(vformat(RTR("Too few arguments for \"%s(%s)\" call. Expected at least %d but received %d."), String(name), arg_list, last_arg_count, args.size()));
_set_error(vformat(RTR("Too many arguments for \"%s(%s)\" call. Expected at most %d but received %d."), String(name), arg_list, last_arg_count, args.size())); } else if (last_arg_count < args.size()) {
_set_error(vformat(RTR("Too many arguments for \"%s(%s)\" call. Expected at most %d but received %d."), String(name), arg_list, last_arg_count, args.size()));
}
} }
return false; return false;