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

Side by Side Diff: test/mjsunit/es8/syntactic-tail-call-parsing.js

Issue 2278413003: Disallow tail calls from async functions and generators (Closed)
Patch Set: Adding test suggested by neis Created 4 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 unified diff | Download patch
« no previous file with comments | « test/message/syntactic-tail-call-generator.out ('k') | test/mjsunit/regress/regress-639270.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --allow-natives-syntax --harmony-explicit-tailcalls 5 // Flags: --allow-natives-syntax --harmony-explicit-tailcalls
6 // Flags: --harmony-do-expressions 6 // Flags: --harmony-do-expressions --harmony-async-await
7 "use strict"; 7 "use strict";
8 8
9 var SyntaxErrorTests = [ 9 var SyntaxErrorTests = [
10 { msg: "Unexpected expression inside tail call", 10 { msg: "Unexpected expression inside tail call",
11 tests: [ 11 tests: [
12 { src: `()=>{ return continue foo ; }`, 12 { src: `()=>{ return continue foo ; }`,
13 err: ` ^^^`, 13 err: ` ^^^`,
14 }, 14 },
15 { src: `()=>{ return continue 42 ; }`, 15 { src: `()=>{ return continue 42 ; }`,
16 err: ` ^^`, 16 err: ` ^^`,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 { src: `()=>{ return bar instanceof continue foo() ; }`, 121 { src: `()=>{ return bar instanceof continue foo() ; }`,
122 err: ` ^^^^^^^^^^^^^^`, 122 err: ` ^^^^^^^^^^^^^^`,
123 }, 123 },
124 { src: `()=>{ return continue foo() in bar ; }`, 124 { src: `()=>{ return continue foo() in bar ; }`,
125 err: ` ^^^^^^^^^^^^^^`, 125 err: ` ^^^^^^^^^^^^^^`,
126 }, 126 },
127 { src: `()=>{ return bar in continue foo() ; }`, 127 { src: `()=>{ return bar in continue foo() ; }`,
128 err: ` ^^^^^^^^^^^^^^`, 128 err: ` ^^^^^^^^^^^^^^`,
129 }, 129 },
130 { src: `()=>{ function* G() { yield continue foo(); } }`, 130 { src: `()=>{ function* G() { yield continue foo(); } }`,
131 err: ` ^^^^^^^^^^^^^^`, 131 err: ` ^^^^^`,
132 },
133 { src: `()=>{ function* G() { return continue foo(); } }`,
134 err: ` ^^^^^`,
132 }, 135 },
133 { src: `()=>{ (1, 2, 3, continue f() ) => {} }`, 136 { src: `()=>{ (1, 2, 3, continue f() ) => {} }`,
134 err: ` ^^^^^^^^^^^^`, 137 err: ` ^^^^^^^^^^^^`,
135 }, 138 },
136 { src: `()=>{ (... continue f()) => {} }`, 139 { src: `()=>{ (... continue f()) => {} }`,
137 err: ` ^^^^^^^^^^^^`, 140 err: ` ^^^^^^^^^^^^`,
138 }, 141 },
139 { src: `()=>{ (a, b, c, ... continue f() ) => {} }`, 142 { src: `()=>{ (a, b, c, ... continue f() ) => {} }`,
140 err: ` ^^^^^^^^^^^^`, 143 err: ` ^^^^^^^^^^^^`,
141 }, 144 },
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 }, 231 },
229 { src: `()=>{ const c = continue foo() }`, 232 { src: `()=>{ const c = continue foo() }`,
230 err: ` ^^^^^^^^^^^^^^^`, 233 err: ` ^^^^^^^^^^^^^^^`,
231 }, 234 },
232 { src: `class A {}; class B extends A { constructor() { return continue fo o () ; } }`, 235 { src: `class A {}; class B extends A { constructor() { return continue fo o () ; } }`,
233 err: ` ^^^^^^^^^^^ ^^^^`, 236 err: ` ^^^^^^^^^^^ ^^^^`,
234 }, 237 },
235 { src: `class A extends continue f () {}; }`, 238 { src: `class A extends continue f () {}; }`,
236 err: ` ^^^^^^^^^^^^^`, 239 err: ` ^^^^^^^^^^^^^`,
237 }, 240 },
241 { src: `async() => continue foo()`,
242 err: ` ^^^^^`,
243 },
238 ], 244 ],
239 }, 245 },
240 { msg: "Tail call expression in try block", 246 { msg: "Tail call expression in try block",
241 tests: [ 247 tests: [
242 { src: `()=>{ try { return continue f ( ) ; } catch(e) {} }`, 248 { src: `()=>{ try { return continue f ( ) ; } catch(e) {} }`,
243 err: ` ^^^^^^^^^^^^^^^^`, 249 err: ` ^^^^^^^^^^^^^^^^`,
244 }, 250 },
245 { src: `()=>{ try { try { smth; } catch(e) { return continue f( ) ; } }` , 251 { src: `()=>{ try { try { smth; } catch(e) { return continue f( ) ; } }` ,
246 err: ` ^^^^^^^^^^^^^^`, 252 err: ` ^^^^^^^^^^^^^^`,
247 }, 253 },
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 `()=>{ return continue a.b.c.foo () ; }`, 310 `()=>{ return continue a.b.c.foo () ; }`,
305 `()=>{ return continue a().b.c().d.foo () ; }`, 311 `()=>{ return continue a().b.c().d.foo () ; }`,
306 `()=>{ return continue foo (1)(2)(3, 4) ; }`, 312 `()=>{ return continue foo (1)(2)(3, 4) ; }`,
307 `()=>{ return continue (0, eval)(); }`, 313 `()=>{ return continue (0, eval)(); }`,
308 `()=>{ return ( continue b() ) ; }`, 314 `()=>{ return ( continue b() ) ; }`,
309 "()=>{ return continue bar`ab cd ef` ; }", 315 "()=>{ return continue bar`ab cd ef` ; }",
310 "()=>{ return continue bar`ab ${cd} ef` ; }", 316 "()=>{ return continue bar`ab ${cd} ef` ; }",
311 `()=>{ return a || continue f() ; }`, 317 `()=>{ return a || continue f() ; }`,
312 `()=>{ return a && continue f() ; }`, 318 `()=>{ return a && continue f() ; }`,
313 `()=>{ return a , continue f() ; }`, 319 `()=>{ return a , continue f() ; }`,
314 `()=>{ function* G() { return continue foo(); } }`,
315 `()=>{ class A { foo() { return continue super.f() ; } } }`, 320 `()=>{ class A { foo() { return continue super.f() ; } } }`,
316 `()=>{ function B() { return continue new.target() ; } }`, 321 `()=>{ function B() { return continue new.target() ; } }`,
317 `()=>{ return continue do { x ? foo() : bar() ; }() }`, 322 `()=>{ return continue do { x ? foo() : bar() ; }() }`,
318 `()=>{ return continue (do { x ? foo() : bar() ; })() }`, 323 `()=>{ return continue (do { x ? foo() : bar() ; })() }`,
319 `()=>{ return do { 1, continue foo() } }`, 324 `()=>{ return do { 1, continue foo() } }`,
320 `()=>{ return do { x ? continue foo() : y } }`, 325 `()=>{ return do { x ? continue foo() : y } }`,
321 `()=>{ return a || (b && continue c()); }`, 326 `()=>{ return a || (b && continue c()); }`,
322 `()=>{ return a && (b || continue c()); }`, 327 `()=>{ return a && (b || continue c()); }`,
323 `()=>{ return a || (b ? c : continue d()); }`, 328 `()=>{ return a || (b ? c : continue d()); }`,
324 `()=>{ return 1, 2, 3, a || (b ? c : continue d()); }`, 329 `()=>{ return 1, 2, 3, a || (b ? c : continue d()); }`,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 (function() { 384 (function() {
380 for (var src of NoErrorTests) { 385 for (var src of NoErrorTests) {
381 print("======================================="); 386 print("=======================================");
382 print("Source | " + src); 387 print("Source | " + src);
383 src = `"use strict"; ` + src; 388 src = `"use strict"; ` + src;
384 Realm.eval(0, src); 389 Realm.eval(0, src);
385 print("PASSED"); 390 print("PASSED");
386 print(); 391 print();
387 } 392 }
388 })(); 393 })();
OLDNEW
« no previous file with comments | « test/message/syntactic-tail-call-generator.out ('k') | test/mjsunit/regress/regress-639270.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698