diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-06-19 21:18:18 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-06-19 21:18:18 +0200 |
commit | ae00187b58cc5ec20ceb2c00c912820c756ed275 (patch) | |
tree | ea7afe68cf0826268484d2d8f1d5029ec6e049d4 /modules/gdscript/gdscript_analyzer.cpp | |
parent | 5f9175f969807410bc077fc9caa0fa53febd4319 (diff) | |
parent | aebbbda08060e0cd130c5a682cd91b6babb18c67 (diff) | |
download | redot-engine-ae00187b58cc5ec20ceb2c00c912820c756ed275.tar.gz |
Merge pull request #77129 from dalexeev/gds-fix-static-var-bugs-part-1
GDScript: Fix some bugs with static variables and functions
Diffstat (limited to 'modules/gdscript/gdscript_analyzer.cpp')
-rw-r--r-- | modules/gdscript/gdscript_analyzer.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index 5052cc074e..e1033c2aab 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -2469,9 +2469,15 @@ void GDScriptAnalyzer::reduce_assignment(GDScriptParser::AssignmentNode *p_assig GDScriptParser::DataType assignee_type = p_assignment->assignee->get_datatype(); - if (assignee_type.is_constant || (p_assignment->assignee->type == GDScriptParser::Node::SUBSCRIPT && static_cast<GDScriptParser::SubscriptNode *>(p_assignment->assignee)->base->is_constant)) { + if (assignee_type.is_constant) { push_error("Cannot assign a new value to a constant.", p_assignment->assignee); return; + } else if (p_assignment->assignee->type == GDScriptParser::Node::SUBSCRIPT && static_cast<GDScriptParser::SubscriptNode *>(p_assignment->assignee)->base->is_constant) { + const GDScriptParser::DataType &base_type = static_cast<GDScriptParser::SubscriptNode *>(p_assignment->assignee)->base->datatype; + if (base_type.kind != GDScriptParser::DataType::SCRIPT && base_type.kind != GDScriptParser::DataType::CLASS) { // Static variables. + push_error("Cannot assign a new value to a constant.", p_assignment->assignee); + return; + } } else if (assignee_type.is_read_only) { push_error("Cannot assign a new value to a read-only property.", p_assignment->assignee); return; @@ -3522,7 +3528,7 @@ void GDScriptAnalyzer::reduce_identifier_from_base(GDScriptParser::IdentifierNod } break; case GDScriptParser::ClassNode::Member::FUNCTION: { - if (is_base && !base.is_meta_type) { + if (is_base && (!base.is_meta_type || member.function->is_static)) { p_identifier->set_datatype(make_callable_type(member.function->info)); return; } |