Skip to content

Commit 9b5a8cd

Browse files
committed
[update] the environment to return once there's been a successful assignment.
1 parent 6f563d1 commit 9b5a8cd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Lamscript/runtime/Environment.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ void Environment::AssignVariable(const parsing::Token& name, std::any value) {
2323

2424
if (lookup != values_.end()) {
2525
lookup->second = value;
26+
return;
2627
}
2728

2829
if (parent_ != nullptr) {
29-
return parent_->AssignVariable(name, value);
30+
parent_->AssignVariable(name, value);
31+
return;
3032
}
3133

3234
throw RuntimeError(name, "Undefined Variable '" + name.Lexeme + "'.");

0 commit comments

Comments
 (0)