Add GDScript warning for standalone expression

This makes the error message clearer as it might be used to call
functions with side effects.
This commit is contained in:
George Marques 2020-01-09 08:30:14 -03:00
parent e7b7dc57fc
commit 7d4fc79eb3
No known key found for this signature in database
GPG key ID: 046BD46A3201E43D
3 changed files with 10 additions and 1 deletions

View file

@ -8274,7 +8274,11 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) {
_mark_line_as_safe(op->line);
_reduce_node_type(op); // Test for safety anyway
#ifdef DEBUG_ENABLED
_add_warning(GDScriptWarning::STANDALONE_EXPRESSION, statement->line);
if (op->op == OperatorNode::OP_TERNARY_IF) {
_add_warning(GDScriptWarning::STANDALONE_TERNARY, statement->line);
} else {
_add_warning(GDScriptWarning::STANDALONE_EXPRESSION, statement->line);
}
#endif // DEBUG_ENABLED
}
}