Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(321)

Unified Diff: test/mjsunit/es6/try-catch-for-of.js

Issue 1318023004: Do not permit binding over catch parameters in for-of (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/try-catch-for-of.js
diff --git a/test/mjsunit/d8-worker-spawn-worker.js b/test/mjsunit/es6/try-catch-for-of.js
similarity index 73%
copy from test/mjsunit/d8-worker-spawn-worker.js
copy to test/mjsunit/es6/try-catch-for-of.js
index a114d8587e0ebc7095565cfebb3634e7fdefbbe7..560aa3118a287a90148ae5b1f3365bc685602c01 100644
--- a/test/mjsunit/d8-worker-spawn-worker.js
+++ b/test/mjsunit/es6/try-catch-for-of.js
@@ -25,16 +25,30 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-if (this.Worker) {
- var workerScript =
- `var w = new Worker('postMessage(42)');
- onmessage = function(parentMsg) {
- w.postMessage(parentMsg);
- var childMsg = w.getMessage();
- postMessage(childMsg);
- };`;
+// Test that we throw syntax errors when users attempt to shadow
+// try-catch bindings with for-of statements.
- var w = new Worker(workerScript);
- w.postMessage(9);
- assertEquals(42, w.getMessage());
+function testEarlyError(s) {
+ assertThrows(function() {
+ eval("(function() { " + s + " })")
+ }, SyntaxError);
+}
+
+testEarlyError("try {} catch (e) { for (var e of []) {} }");
+
+assertThrows(function () {
+ try {
+ throw null;
+ } catch (e) {
+ eval("for (var e of []) {}");
+ }
+}, SyntaxError);
+
+// For-in statements should be fine, though.
+
+try {} catch (f) { for (var f in []) {} }
+try {
+ throw null;
+} catch (g) {
+ eval("for (var g in []) {}");
}
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698