You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Merge pull request #72925 from vonagam/fix-enum-typed-array-error
GDScript: Fix error about enum typed arrays
This commit is contained in:
@@ -4252,6 +4252,7 @@ Variant GDScriptAnalyzer::make_subscript_reduced_value(GDScriptParser::Subscript
|
|||||||
Array GDScriptAnalyzer::make_array_from_element_datatype(const GDScriptParser::DataType &p_element_datatype, const GDScriptParser::Node *p_source_node) {
|
Array GDScriptAnalyzer::make_array_from_element_datatype(const GDScriptParser::DataType &p_element_datatype, const GDScriptParser::Node *p_source_node) {
|
||||||
Array array;
|
Array array;
|
||||||
|
|
||||||
|
if (p_element_datatype.builtin_type == Variant::OBJECT) {
|
||||||
Ref<Script> script_type = p_element_datatype.script_type;
|
Ref<Script> script_type = p_element_datatype.script_type;
|
||||||
if (p_element_datatype.kind == GDScriptParser::DataType::CLASS && script_type.is_null()) {
|
if (p_element_datatype.kind == GDScriptParser::DataType::CLASS && script_type.is_null()) {
|
||||||
Error err = OK;
|
Error err = OK;
|
||||||
@@ -4264,6 +4265,9 @@ Array GDScriptAnalyzer::make_array_from_element_datatype(const GDScriptParser::D
|
|||||||
}
|
}
|
||||||
|
|
||||||
array.set_typed(p_element_datatype.builtin_type, p_element_datatype.native_type, script_type);
|
array.set_typed(p_element_datatype.builtin_type, p_element_datatype.native_type, script_type);
|
||||||
|
} else {
|
||||||
|
array.set_typed(p_element_datatype.builtin_type, StringName(), Variant());
|
||||||
|
}
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -201,6 +201,10 @@ func test():
|
|||||||
assert(str(typed_enums) == '[391]')
|
assert(str(typed_enums) == '[391]')
|
||||||
assert(typed_enums.get_typed_builtin() == TYPE_INT)
|
assert(typed_enums.get_typed_builtin() == TYPE_INT)
|
||||||
|
|
||||||
|
const const_enums: Array[E] = []
|
||||||
|
assert(const_enums.get_typed_builtin() == TYPE_INT)
|
||||||
|
assert(const_enums.get_typed_class_name() == &'')
|
||||||
|
|
||||||
|
|
||||||
var a := A.new()
|
var a := A.new()
|
||||||
var typed_natives: Array[RefCounted] = [a]
|
var typed_natives: Array[RefCounted] = [a]
|
||||||
|
|||||||
Reference in New Issue
Block a user