Browse Source

Merge pull request #110240 from westenral/add_int_division_warnings

Add checks for integer vectors for integer division warning
Thaddeus Crews 2 weeks ago
parent
commit
b9730c0b2e
1 changed files with 7 additions and 1 deletions
  1. 7 1
      modules/gdscript/gdscript_analyzer.cpp

+ 7 - 1
modules/gdscript/gdscript_analyzer.cpp

@@ -3102,7 +3102,13 @@ void GDScriptAnalyzer::reduce_binary_op(GDScriptParser::BinaryOpNode *p_binary_o
 	}
 	}
 
 
 #ifdef DEBUG_ENABLED
 #ifdef DEBUG_ENABLED
-	if (p_binary_op->variant_op == Variant::OP_DIVIDE && left_type.builtin_type == Variant::INT && right_type.builtin_type == Variant::INT) {
+	if (p_binary_op->variant_op == Variant::OP_DIVIDE &&
+			(left_type.builtin_type == Variant::INT ||
+					left_type.builtin_type == Variant::VECTOR2I ||
+					left_type.builtin_type == Variant::VECTOR3I ||
+					left_type.builtin_type == Variant::VECTOR4I) &&
+			(right_type.builtin_type == Variant::INT ||
+					right_type.builtin_type == left_type.builtin_type)) {
 		parser->push_warning(p_binary_op, GDScriptWarning::INTEGER_DIVISION);
 		parser->push_warning(p_binary_op, GDScriptWarning::INTEGER_DIVISION);
 	}
 	}
 #endif // DEBUG_ENABLED
 #endif // DEBUG_ENABLED