1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-19 00:45:08 +00:00

AK+LibWasm+LibJS: Disallow Variant.has() on types that aren't contained

Checking for this (and get()'ing it) is always invalid, so let's just
disallow it.
This also finds two bugs where the code is checking for types that can
never actually be in the variant (which was actually a refactor
artifact).
This commit is contained in:
Ali Mohammad Pur 2021-06-02 18:11:48 +04:30 committed by Andreas Kling
parent 87ff76bd57
commit ea7ba34a31
3 changed files with 16 additions and 16 deletions

View file

@ -1609,7 +1609,7 @@ NonnullRefPtr<VariableDeclaration> Parser::parse_variable_declaration(bool for_l
init = parse_expression(2);
} else if (!for_loop_variable_declaration && declaration_kind == DeclarationKind::Const) {
syntax_error("Missing initializer in 'const' variable declaration");
} else if (target.has<BindingPattern>()) {
} else if (target.has<NonnullRefPtr<BindingPattern>>()) {
syntax_error("Missing initializer in destructuring assignment");
}