summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/gdscript_parser.cpp
diff options
context:
space:
mode:
authorcdemirer <41021322+cdemirer@users.noreply.github.com>2022-07-04 12:30:39 +0300
committercdemirer <41021322+cdemirer@users.noreply.github.com>2022-07-04 12:30:39 +0300
commitdbdf0174b4a7947fabb59e275f2ffb5bf494451a (patch)
tree20c51ffc2416445419275727826f327ccbf3ad56 /modules/gdscript/gdscript_parser.cpp
parent5b3b06187b79ff859bb7da81362d2234c6e64a50 (diff)
downloadredot-engine-dbdf0174b4a7947fabb59e275f2ffb5bf494451a.tar.gz
Do error when for variable conflicts with a variable in scope
Diffstat (limited to 'modules/gdscript/gdscript_parser.cpp')
-rw-r--r--modules/gdscript/gdscript_parser.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index ca430b0f72..80fb9c8415 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -1748,6 +1748,10 @@ GDScriptParser::ForNode *GDScriptParser::parse_for() {
SuiteNode *suite = alloc_node<SuiteNode>();
if (n_for->variable) {
+ const SuiteNode::Local &local = current_suite->get_local(n_for->variable->name);
+ if (local.type != SuiteNode::Local::UNDEFINED) {
+ push_error(vformat(R"(There is already a %s named "%s" declared in this scope.)", local.get_name(), n_for->variable->name), n_for->variable);
+ }
suite->add_local(SuiteNode::Local(n_for->variable, current_function));
}
suite->parent_for = n_for;