1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

regression: static func can't access const fix

(cherry picked from commit e7f056dfac)
This commit is contained in:
Thakee Nathees
2020-05-13 06:07:22 +05:30
committed by Rémi Verschelde
parent dd7f9b1c08
commit 6d7fb3d322
2 changed files with 7 additions and 4 deletions

View File

@@ -7338,7 +7338,7 @@ GDScriptParser::DataType GDScriptParser::_reduce_function_call_type(const Operat
return return_type;
}
bool GDScriptParser::_get_member_type(const DataType &p_base_type, const StringName &p_member, DataType &r_member_type) const {
bool GDScriptParser::_get_member_type(const DataType &p_base_type, const StringName &p_member, DataType &r_member_type, bool *r_is_const) const {
DataType base_type = p_base_type;
// Check classes in current file
@@ -7349,6 +7349,8 @@ bool GDScriptParser::_get_member_type(const DataType &p_base_type, const StringN
while (base) {
if (base->constant_expressions.has(p_member)) {
if (r_is_const)
*r_is_const = true;
r_member_type = base->constant_expressions[p_member].expression->get_datatype();
return true;
}
@@ -7572,8 +7574,9 @@ GDScriptParser::DataType GDScriptParser::_reduce_identifier_type(const DataType
base_type = DataType(*p_base_type);
}
if (_get_member_type(base_type, p_identifier, member_type)) {
if (!p_base_type && current_function && current_function->_static) {
bool is_const = false;
if (_get_member_type(base_type, p_identifier, member_type, &is_const)) {
if (!p_base_type && current_function && current_function->_static && !is_const) {
_set_error("Can't access member variable (\"" + p_identifier.operator String() + "\") from a static function.", p_line);
return DataType();
}