Fix wrong counting of function argument usage
There's no need to subtract 1 from the assignment usages because it's not incremented anywhere else. Also put back the assignment with operators because they should not count as usage if the argument is on the left side.
This commit is contained in:
parent
119bf23720
commit
bb20e420af
|
@ -858,14 +858,26 @@ 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()) {
|
||||||
|
case GDScriptTokenizer::TK_OP_ASSIGN_ADD:
|
||||||
|
case GDScriptTokenizer::TK_OP_ASSIGN_BIT_AND:
|
||||||
|
case GDScriptTokenizer::TK_OP_ASSIGN_BIT_OR:
|
||||||
|
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
|
// Assignment is not really usage
|
||||||
current_function->arguments_usage.write[arg_idx] = current_function->arguments_usage[arg_idx] - 1;
|
} break;
|
||||||
} else {
|
default: {
|
||||||
current_function->arguments_usage.write[arg_idx] = current_function->arguments_usage[arg_idx] + 1;
|
current_function->arguments_usage.write[arg_idx] = current_function->arguments_usage[arg_idx] + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif // DEBUG_ENABLED
|
#endif // DEBUG_ENABLED
|
||||||
IdentifierNode *id = alloc_node<IdentifierNode>();
|
IdentifierNode *id = alloc_node<IdentifierNode>();
|
||||||
id->name = identifier;
|
id->name = identifier;
|
||||||
|
|
Loading…
Reference in New Issue