瀏覽代碼

Prevent non explicit inferring parameter from null

jmb462 4 年之前
父節點
當前提交
b9219bedf7
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      modules/gdscript/gdscript_analyzer.cpp

+ 4 - 0
modules/gdscript/gdscript_analyzer.cpp

@@ -1478,6 +1478,10 @@ void GDScriptAnalyzer::resolve_parameter(GDScriptParser::ParameterNode *p_parame
 		}
 		}
 	}
 	}
 
 
+	if (result.builtin_type == Variant::Type::NIL && result.type_source == GDScriptParser::DataType::ANNOTATED_INFERRED && p_parameter->datatype_specifier == nullptr) {
+		push_error(vformat(R"(Could not infer the type of the variable "%s" because the initial value is "null".)", p_parameter->identifier->name), p_parameter->default_value);
+	}
+
 	p_parameter->set_datatype(result);
 	p_parameter->set_datatype(result);
 }
 }