You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-18 14:21:41 +00:00
Merge pull request #41516 from Lunatoid/allow-object-new
Fixed ParseError when calling Object.new()
This commit is contained in:
@@ -2279,10 +2279,12 @@ void GDScriptAnalyzer::reduce_identifier(GDScriptParser::IdentifierNode *p_ident
|
|||||||
StringName name = p_identifier->name;
|
StringName name = p_identifier->name;
|
||||||
p_identifier->source = GDScriptParser::IdentifierNode::UNDEFINED_SOURCE;
|
p_identifier->source = GDScriptParser::IdentifierNode::UNDEFINED_SOURCE;
|
||||||
|
|
||||||
// Check globals.
|
// Check globals. We make an exception for Variant::OBJECT because it's the base class for
|
||||||
if (GDScriptParser::get_builtin_type(name) < Variant::VARIANT_MAX) {
|
// non-builtin types so we allow doing e.g. Object.new()
|
||||||
|
Variant::Type builtin_type = GDScriptParser::get_builtin_type(name);
|
||||||
|
if (builtin_type != Variant::OBJECT && builtin_type < Variant::VARIANT_MAX) {
|
||||||
if (can_be_builtin) {
|
if (can_be_builtin) {
|
||||||
p_identifier->set_datatype(make_builtin_meta_type(GDScriptParser::get_builtin_type(name)));
|
p_identifier->set_datatype(make_builtin_meta_type(builtin_type));
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
push_error(R"(Builtin type cannot be used as a name on its own.)", p_identifier);
|
push_error(R"(Builtin type cannot be used as a name on its own.)", p_identifier);
|
||||||
|
|||||||
Reference in New Issue
Block a user