mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 19:04:58 +00:00
LibJS: Throw on assignment of an const variable
Was stubbed out as an assert, should be handled with a runtime exception.
This commit is contained in:
committed by
Andreas Kling
parent
8e87d340c3
commit
0d41e542b7
@@ -145,8 +145,10 @@ void Interpreter::set_variable(const FlyString& name, Value value, bool first_as
|
||||
|
||||
auto possible_match = scope.variables.get(name);
|
||||
if (possible_match.has_value()) {
|
||||
if (!first_assignment && possible_match.value().declaration_kind == DeclarationKind::Const)
|
||||
ASSERT_NOT_REACHED();
|
||||
if (!first_assignment && possible_match.value().declaration_kind == DeclarationKind::Const) {
|
||||
throw_exception<TypeError>("Assignment to constant variable");
|
||||
return;
|
||||
}
|
||||
|
||||
scope.variables.set(move(name), { move(value), possible_match.value().declaration_kind });
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user