зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1533620 - Verify that catch scope has correct item. r=Yoric
Depends on D22647 Differential Revision: https://phabricator.services.mozilla.com/D22648 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
de43947668
Коммит
1f1e82a655
|
@ -2135,7 +2135,10 @@ JS::Result<LexicalScopeNode*> BinASTParser<Tok>::parseInterfaceCatchClause(
|
|||
MOZ_TRY(parseAssertedBoundNamesScope());
|
||||
|
||||
BINJS_MOZ_TRY_DECL(binding, parseBinding());
|
||||
|
||||
if (!currentScope.lookupDeclaredName(
|
||||
binding->template as<NameNode>().atom())) {
|
||||
return raiseError("Missing catch variable in scope");
|
||||
}
|
||||
BINJS_MOZ_TRY_DECL(body, parseBlock());
|
||||
|
||||
MOZ_TRY(checkClosedVars(currentScope));
|
||||
|
|
|
@ -688,6 +688,12 @@ CatchClause:
|
|||
ParseContext::Statement stmt(pc_, StatementKind::Catch);
|
||||
ParseContext::Scope currentScope(cx_, pc_, usedNames_);
|
||||
BINJS_TRY(currentScope.init(pc_));
|
||||
fields:
|
||||
binding:
|
||||
after: |
|
||||
if (!currentScope.lookupDeclaredName(binding->template as<NameNode>().atom())) {
|
||||
return raiseError("Missing catch variable in scope");
|
||||
}
|
||||
build: |
|
||||
MOZ_TRY(checkClosedVars(currentScope));
|
||||
BINJS_TRY_DECL(bindings,
|
||||
|
|
Двоичный файл не отображается.
|
@ -0,0 +1 @@
|
|||
// |jit-test| error:SyntaxError
|
Двоичный файл не отображается.
|
@ -0,0 +1 @@
|
|||
// |jit-test| error:SyntaxError
|
|
@ -0,0 +1,3 @@
|
|||
try {
|
||||
} catch (e) {
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
def filter_ast(ast):
|
||||
# catch with missing AssertedBoundName
|
||||
import filter_utils as utils
|
||||
|
||||
utils.assert_interface(ast, 'Script')
|
||||
global_stmts = utils.get_field(ast, 'statements')
|
||||
|
||||
try_stmt = utils.get_element(global_stmts, 0)
|
||||
utils.assert_interface(try_stmt, 'TryCatchStatement')
|
||||
|
||||
catch = utils.get_field(try_stmt, 'catchClause')
|
||||
utils.assert_interface(catch, 'CatchClause')
|
||||
|
||||
scope = utils.get_field(catch, 'bindingScope')
|
||||
utils.assert_interface(scope, 'AssertedBoundNamesScope')
|
||||
|
||||
names = utils.get_field(scope, 'boundNames')
|
||||
utils.remove_element(names, 0)
|
||||
|
||||
return ast
|
|
@ -0,0 +1,3 @@
|
|||
try {
|
||||
} catch (e) {
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
def filter_ast(ast):
|
||||
# catch with unmatched AssertedBoundName
|
||||
import filter_utils as utils
|
||||
|
||||
utils.assert_interface(ast, 'Script')
|
||||
global_stmts = utils.get_field(ast, 'statements')
|
||||
|
||||
try_stmt = utils.get_element(global_stmts, 0)
|
||||
utils.assert_interface(try_stmt, 'TryCatchStatement')
|
||||
|
||||
catch = utils.get_field(try_stmt, 'catchClause')
|
||||
utils.assert_interface(catch, 'CatchClause')
|
||||
|
||||
scope = utils.get_field(catch, 'bindingScope')
|
||||
utils.assert_interface(scope, 'AssertedBoundNamesScope')
|
||||
|
||||
names = utils.get_field(scope, 'boundNames')
|
||||
bound_name = utils.get_element(names, 0)
|
||||
utils.assert_interface(bound_name, 'AssertedBoundName')
|
||||
|
||||
name = utils.get_field(bound_name, 'name')
|
||||
|
||||
utils.set_identifier_name(name, 'b')
|
||||
|
||||
return ast
|
Загрузка…
Ссылка в новой задаче