|
@@ -108,14 +108,14 @@ void Interpreter::declare_variable(String name, DeclarationType declaration_type
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-void Interpreter::set_variable(String name, Value value)
|
|
|
|
|
|
+void Interpreter::set_variable(String name, Value value, bool first_assignment)
|
|
{
|
|
{
|
|
for (ssize_t i = m_scope_stack.size() - 1; i >= 0; --i) {
|
|
for (ssize_t i = m_scope_stack.size() - 1; i >= 0; --i) {
|
|
auto& scope = m_scope_stack.at(i);
|
|
auto& scope = m_scope_stack.at(i);
|
|
|
|
|
|
auto possible_match = scope.variables.get(name);
|
|
auto possible_match = scope.variables.get(name);
|
|
if (possible_match.has_value()) {
|
|
if (possible_match.has_value()) {
|
|
- if (possible_match.value().declaration_type == DeclarationType::Const)
|
|
|
|
|
|
+ if (!first_assignment && possible_match.value().declaration_type == DeclarationType::Const)
|
|
ASSERT_NOT_REACHED();
|
|
ASSERT_NOT_REACHED();
|
|
|
|
|
|
scope.variables.set(move(name), { move(value), possible_match.value().declaration_type });
|
|
scope.variables.set(move(name), { move(value), possible_match.value().declaration_type });
|