8039047: Parser accepts conditional catch clauses even when --no-syntax-extensions / -nse option is passed
Reviewed-by: lagergren, attila
This commit is contained in:
parent
1eab51598e
commit
79fba7993d
@ -1700,9 +1700,11 @@ loop:
|
||||
// ECMA 12.4.1 strict mode restrictions
|
||||
verifyStrictIdent(exception, "catch argument");
|
||||
|
||||
// Check for conditional catch.
|
||||
// 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;
|
||||
if (type == IF) {
|
||||
if (!env._no_syntax_extensions && type == IF) {
|
||||
next();
|
||||
// Get the exception condition.
|
||||
ifExpression = expression();
|
||||
|
35
nashorn/test/script/error/JDK-8039047.js
Normal file
35
nashorn/test/script/error/JDK-8039047.js
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* JDK-8039047: Parser accepts conditional catch clauses even when --no-syntax-extensions / -nse option is passed
|
||||
*
|
||||
* @option --no-syntax-extensions
|
||||
* @test/compile-error
|
||||
*/
|
||||
|
||||
try {
|
||||
func()
|
||||
} catch (e if e instanceof ReferenceError) {
|
||||
print("Got ReferenceError " + e);
|
||||
}
|
6
nashorn/test/script/error/JDK-8039047.js.EXPECTED
Normal file
6
nashorn/test/script/error/JDK-8039047.js.EXPECTED
Normal file
@ -0,0 +1,6 @@
|
||||
test/script/error/JDK-8039047.js:33:11 Expected ) but found if
|
||||
} catch (e if e instanceof ReferenceError) {
|
||||
^
|
||||
test/script/error/JDK-8039047.js:35:0 Expected eof but found }
|
||||
}
|
||||
^
|
Loading…
Reference in New Issue
Block a user