mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 00:13:30 +00:00
GDScript: Add CONFUSABLE_CAPTURE_REASSIGNMENT
warning
This commit is contained in:
parent
cae2f853dc
commit
68898dbcc9
7 changed files with 88 additions and 0 deletions
|
@ -2663,6 +2663,21 @@ void GDScriptAnalyzer::reduce_assignment(GDScriptParser::AssignmentNode *p_assig
|
|||
|
||||
reduce_expression(p_assignment->assignee);
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
{
|
||||
GDScriptParser::ExpressionNode *base = p_assignment->assignee;
|
||||
while (base && base->type == GDScriptParser::Node::SUBSCRIPT) {
|
||||
base = static_cast<GDScriptParser::SubscriptNode *>(base)->base;
|
||||
}
|
||||
if (base && base->type == GDScriptParser::Node::IDENTIFIER) {
|
||||
GDScriptParser::IdentifierNode *id = static_cast<GDScriptParser::IdentifierNode *>(base);
|
||||
if (current_lambda && current_lambda->captures_indices.has(id->name)) {
|
||||
parser->push_warning(p_assignment, GDScriptWarning::CONFUSABLE_CAPTURE_REASSIGNMENT, id->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (p_assignment->assigned_value == nullptr || p_assignment->assignee == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue