fixed parser error when indexing a dictionary.

Fix: #41707
This commit is contained in:
Thakee Nathees 2020-09-02 20:38:49 +05:30
parent 358e209fa0
commit 4fc14e8e11

View File

@ -2073,6 +2073,18 @@ void GDScriptAnalyzer::reduce_identifier_from_base(GDScriptParser::IdentifierNod
push_error(vformat(R"(Cannot find constant "%s" on type "%s".)", name, base.to_string()), p_identifier); push_error(vformat(R"(Cannot find constant "%s" on type "%s".)", name, base.to_string()), p_identifier);
} }
} else { } else {
switch (base.builtin_type) {
case Variant::NIL: {
push_error(vformat(R"(Invalid get index "%s" on base Nil)", name), p_identifier);
return;
}
case Variant::DICTIONARY: {
GDScriptParser::DataType dummy;
dummy.kind = GDScriptParser::DataType::VARIANT;
p_identifier->set_datatype(dummy);
return;
}
default: {
Callable::CallError temp; Callable::CallError temp;
Variant dummy = Variant::construct(base.builtin_type, nullptr, 0, temp); Variant dummy = Variant::construct(base.builtin_type, nullptr, 0, temp);
List<PropertyInfo> properties; List<PropertyInfo> properties;
@ -2086,6 +2098,8 @@ void GDScriptAnalyzer::reduce_identifier_from_base(GDScriptParser::IdentifierNod
} }
push_error(vformat(R"(Cannot find property "%s" on base "%s".)", name, base.to_string()), p_identifier); push_error(vformat(R"(Cannot find property "%s" on base "%s".)", name, base.to_string()), p_identifier);
} }
}
}
return; return;
} }