mirror of
https://github.com/godotengine/godot.git
synced 2025-10-25 18:54:43 +00:00
Merge pull request #34918 from vnen/gdscript-assign-op
GDScript: enable type checks on release mode
This commit is contained in:
commit
c456d87ee6
3 changed files with 38 additions and 9 deletions
|
|
@ -8192,11 +8192,14 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) {
|
|||
if (lh_type.has_type && rh_type.may_yield && op->arguments[1]->type == Node::TYPE_OPERATOR) {
|
||||
_add_warning(GDScriptWarning::FUNCTION_MAY_YIELD, op->line, _find_function_name(static_cast<OperatorNode *>(op->arguments[1])));
|
||||
}
|
||||
#endif // DEBUG_ENABLED
|
||||
|
||||
bool type_match = check_types;
|
||||
#endif // DEBUG_ENABLED
|
||||
if (check_types && !_is_type_compatible(lh_type, rh_type)) {
|
||||
#ifdef DEBUG_ENABLED
|
||||
type_match = false;
|
||||
#endif // DEBUG_ENABLED
|
||||
|
||||
// Try supertype test
|
||||
if (_is_type_compatible(rh_type, lh_type)) {
|
||||
_mark_line_as_unsafe(op->line);
|
||||
|
|
@ -8227,7 +8230,9 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) {
|
|||
|
||||
op->arguments.write[1] = convert_call;
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
type_match = true; // Since we are converting, the type is matching
|
||||
#endif // DEBUG_ENABLED
|
||||
}
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (lh_type.builtin_type == Variant::INT && rh_type.builtin_type == Variant::REAL) {
|
||||
|
|
@ -8240,8 +8245,10 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) {
|
|||
if (!rh_type.has_type && (op->op != OperatorNode::OP_ASSIGN || lh_type.has_type || op->arguments[0]->type == Node::TYPE_OPERATOR)) {
|
||||
_mark_line_as_unsafe(op->line);
|
||||
}
|
||||
#endif // DEBUG_ENABLED
|
||||
op->datatype.has_type = type_match;
|
||||
#else
|
||||
op->datatype.has_type = false;
|
||||
#endif // DEBUG_ENABLED
|
||||
} break;
|
||||
case OperatorNode::OP_CALL:
|
||||
case OperatorNode::OP_PARENT_CALL: {
|
||||
|
|
@ -8484,11 +8491,8 @@ Error GDScriptParser::_parse(const String &p_base_path) {
|
|||
current_class = main_class;
|
||||
current_function = NULL;
|
||||
current_block = NULL;
|
||||
#ifdef DEBUG_ENABLED
|
||||
|
||||
if (for_completion) check_types = false;
|
||||
#else
|
||||
check_types = false;
|
||||
#endif
|
||||
|
||||
// Resolve all class-level stuff before getting into function blocks
|
||||
_check_class_level_types(main_class);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue