mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Merge pull request #32919 from vnen/gdscript-unused-args
Fix wrong counting of function argument usage
This commit is contained in:
commit
8228b93fcd
1 changed files with 17 additions and 5 deletions
|
|
@ -858,11 +858,23 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
|
||||||
if (current_function) {
|
if (current_function) {
|
||||||
int arg_idx = current_function->arguments.find(identifier);
|
int arg_idx = current_function->arguments.find(identifier);
|
||||||
if (arg_idx != -1) {
|
if (arg_idx != -1) {
|
||||||
if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_ASSIGN) {
|
switch (tokenizer->get_token()) {
|
||||||
// Assignment is not really usage
|
case GDScriptTokenizer::TK_OP_ASSIGN_ADD:
|
||||||
current_function->arguments_usage.write[arg_idx] = current_function->arguments_usage[arg_idx] - 1;
|
case GDScriptTokenizer::TK_OP_ASSIGN_BIT_AND:
|
||||||
} else {
|
case GDScriptTokenizer::TK_OP_ASSIGN_BIT_OR:
|
||||||
current_function->arguments_usage.write[arg_idx] = current_function->arguments_usage[arg_idx] + 1;
|
case GDScriptTokenizer::TK_OP_ASSIGN_BIT_XOR:
|
||||||
|
case GDScriptTokenizer::TK_OP_ASSIGN_DIV:
|
||||||
|
case GDScriptTokenizer::TK_OP_ASSIGN_MOD:
|
||||||
|
case GDScriptTokenizer::TK_OP_ASSIGN_MUL:
|
||||||
|
case GDScriptTokenizer::TK_OP_ASSIGN_SHIFT_LEFT:
|
||||||
|
case GDScriptTokenizer::TK_OP_ASSIGN_SHIFT_RIGHT:
|
||||||
|
case GDScriptTokenizer::TK_OP_ASSIGN_SUB:
|
||||||
|
case GDScriptTokenizer::TK_OP_ASSIGN: {
|
||||||
|
// Assignment is not really usage
|
||||||
|
} break;
|
||||||
|
default: {
|
||||||
|
current_function->arguments_usage.write[arg_idx] = current_function->arguments_usage[arg_idx] + 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue