< prev index next >
src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java
Print this page
*** 2605,2621 ****
final int catchLine = line;
final long catchToken = token;
next();
expect(LPAREN);
! // FIXME: ES6 catch parameter can be a BindingIdentifier or a BindingPattern
! // We need to generalize this here!
// http://www.ecma-international.org/ecma-262/6.0/
! final IdentNode exception = getIdent();
!
// ECMA 12.4.1 strict mode restrictions
! verifyStrictIdent(exception, "catch argument");
// Nashorn extension: catch clause can have optional
// condition. So, a single try can have more than one
// catch clause each with it's own condition.
final Expression ifExpression;
--- 2605,2631 ----
final int catchLine = line;
final long catchToken = token;
next();
expect(LPAREN);
! // ES6 catch parameter can be a BindingIdentifier or a BindingPattern
// http://www.ecma-international.org/ecma-262/6.0/
! final String contextString = "catch argument";
! final Expression exception = bindingIdentifierOrPattern(contextString);
! final boolean isDestructuring = !(exception instanceof IdentNode);
! if (isDestructuring) {
! verifyDestructuringBindingPattern(exception, new Consumer<IdentNode>() {
! @Override
! public void accept(final IdentNode identNode) {
! verifyIdent(identNode, contextString);
! }
! });
! } else {
// ECMA 12.4.1 strict mode restrictions
! verifyStrictIdent((IdentNode) exception, "catch argument");
! }
!
// Nashorn extension: catch clause can have optional
// condition. So, a single try can have more than one
// catch clause each with it's own condition.
final Expression ifExpression;
< prev index next >