Forráskód Böngészése

Merge pull request #88020 from emre0altan/match-null-crashes-GDScript-compiler

GDScript: Set `has_type` false if it is `BUILTIN` but `Variant::NIL`
Rémi Verschelde 1 éve
szülő
commit
77666286b7

+ 1 - 1
modules/gdscript/gdscript_byte_codegen.cpp

@@ -429,7 +429,7 @@ void GDScriptByteCodeGenerator::set_initial_line(int p_line) {
 	(m_var.type.has_type && m_var.type.kind == GDScriptDataType::BUILTIN)
 
 #define IS_BUILTIN_TYPE(m_var, m_type) \
-	(m_var.type.has_type && m_var.type.kind == GDScriptDataType::BUILTIN && m_var.type.builtin_type == m_type)
+	(m_var.type.has_type && m_var.type.kind == GDScriptDataType::BUILTIN && m_var.type.builtin_type == m_type && m_type != Variant::NIL)
 
 void GDScriptByteCodeGenerator::write_type_adjust(const Address &p_target, Variant::Type p_new_type) {
 	switch (p_new_type) {

+ 6 - 0
modules/gdscript/tests/scripts/runtime/features/match_test_null.gd

@@ -0,0 +1,6 @@
+func test():
+	match null:
+		null:
+			print('null matched')
+		_:
+			pass

+ 2 - 0
modules/gdscript/tests/scripts/runtime/features/match_test_null.out

@@ -0,0 +1,2 @@
+GDTEST_OK
+null matched