Changeset 217200 in webkit
- Timestamp:
- May 21, 2017 10:47:33 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r217199 r217200 1 2017-05-21 Saam Barati <sbarati@apple.com> 2 3 We incorrectly throw a syntax error when declaring a top level for-loop iteration variable the same as a parameter 4 https://bugs.webkit.org/show_bug.cgi?id=171041 5 <rdar://problem/32082516> 6 7 Reviewed by Yusuke Suzuki. 8 9 * stress/lexical-scoping-for-loop.js: Added. 10 (assert): 11 (test1): 12 (test2): 13 (test3): 14 (test4): 15 (test5): 16 (test6): 17 (let.test7): 18 (let.test8): 19 (let.test9): 20 (let.test10): 21 (let.test11): 22 (let.test12): 23 1 24 2017-05-19 Yusuke Suzuki <utatane.tea@gmail.com> 2 25 -
trunk/LayoutTests/ChangeLog
r217197 r217200 1 2017-05-21 Saam Barati <sbarati@apple.com> 2 3 We incorrectly throw a syntax error when declaring a top level for-loop iteration variable the same as a parameter 4 https://bugs.webkit.org/show_bug.cgi?id=171041 5 <rdar://problem/32082516> 6 7 Reviewed by Yusuke Suzuki. 8 9 * js/parser-syntax-check-expected.txt: 10 * js/script-tests/parser-syntax-check.js: 11 1 12 2017-05-21 Antti Koivisto <antti@apple.com> 2 13 -
trunk/LayoutTests/js/parser-syntax-check-expected.txt
r216934 r217200 557 557 PASS Invalid: "for (let {i} = 20 in b) { }". Produced the following syntax error: "SyntaxError: Cannot assign to the loop variable inside a for-in loop header." 558 558 PASS Invalid: "function f() { for (let {i} = 20 in b) { } }". Produced the following syntax error: "SyntaxError: Cannot assign to the loop variable inside a for-in loop header." 559 PASS Valid: "function x(i) { for (let i in {}) { } }" 560 PASS Valid: "function f() { function x(i) { for (let i in {}) { } } }" 561 PASS Valid: "function x(i) { for (let i of []) { } }" 562 PASS Valid: "function f() { function x(i) { for (let i of []) { } } }" 563 PASS Valid: "function x(i) { for (let i of []) { } }" 564 PASS Valid: "function f() { function x(i) { for (let i of []) { } } }" 565 PASS Valid: "function x(i) { for (let i; false; ) { } }" 566 PASS Valid: "function f() { function x(i) { for (let i; false; ) { } } }" 567 PASS Valid: "let f = (i) => { for (let i in {}) { } }" 568 PASS Valid: "function f() { let f = (i) => { for (let i in {}) { } } }" 569 PASS Valid: "let f = (i) => { for (let i of []) { } }" 570 PASS Valid: "function f() { let f = (i) => { for (let i of []) { } } }" 571 PASS Valid: "let f = (i) => { for (let i of []) { } }" 572 PASS Valid: "function f() { let f = (i) => { for (let i of []) { } } }" 573 PASS Valid: "let f = (i) => { for (let i; false; ) { } }" 574 PASS Valid: "function f() { let f = (i) => { for (let i; false; ) { } } }" 575 PASS Valid: "function* x(i) { for (let i in {}) { } }" 576 PASS Valid: "function f() { function* x(i) { for (let i in {}) { } } }" 577 PASS Valid: "function* x(i) { for (let i of []) { } }" 578 PASS Valid: "function f() { function* x(i) { for (let i of []) { } } }" 579 PASS Valid: "function* x(i) { for (let i of []) { } }" 580 PASS Valid: "function f() { function* x(i) { for (let i of []) { } } }" 581 PASS Valid: "function* x(i) { for (let i; false; ) { } }" 582 PASS Valid: "function f() { function* x(i) { for (let i; false; ) { } } }" 583 PASS Valid: "function x(i) { for (const i in {}) { } }" 584 PASS Valid: "function f() { function x(i) { for (const i in {}) { } } }" 585 PASS Valid: "function x(i) { for (const i of []) { } }" 586 PASS Valid: "function f() { function x(i) { for (const i of []) { } } }" 587 PASS Valid: "function x(i) { for (const i of []) { } }" 588 PASS Valid: "function f() { function x(i) { for (const i of []) { } } }" 589 PASS Valid: "function x(i) { for (const i = 20; false; ) { } }" 590 PASS Valid: "function f() { function x(i) { for (const i = 20; false; ) { } } }" 591 PASS Valid: "let f = (i) => { for (const i in {}) { } }" 592 PASS Valid: "function f() { let f = (i) => { for (const i in {}) { } } }" 593 PASS Valid: "let f = (i) => { for (const i of []) { } }" 594 PASS Valid: "function f() { let f = (i) => { for (const i of []) { } } }" 595 PASS Valid: "let f = (i) => { for (const i of []) { } }" 596 PASS Valid: "function f() { let f = (i) => { for (const i of []) { } } }" 597 PASS Valid: "let f = (i) => { for (const i = 20; false; ) { } }" 598 PASS Valid: "function f() { let f = (i) => { for (const i = 20; false; ) { } } }" 599 PASS Valid: "function* x(i) { for (const i in {}) { } }" 600 PASS Valid: "function f() { function* x(i) { for (const i in {}) { } } }" 601 PASS Valid: "function* x(i) { for (const i of []) { } }" 602 PASS Valid: "function f() { function* x(i) { for (const i of []) { } } }" 603 PASS Valid: "function* x(i) { for (const i of []) { } }" 604 PASS Valid: "function f() { function* x(i) { for (const i of []) { } } }" 605 PASS Valid: "function* x(i) { for (const i = 20; false; ) { } }" 606 PASS Valid: "function f() { function* x(i) { for (const i = 20; false; ) { } } }" 559 607 try statement 560 608 PASS Invalid: "try { break } catch(e) {}". Produced the following syntax error: "SyntaxError: 'break' is only valid inside a switch or loop statement." -
trunk/LayoutTests/js/script-tests/parser-syntax-check.js
r216934 r217200 372 372 invalid("for (const {i} = 20 in b) { }"); 373 373 invalid("for (let {i} = 20 in b) { }"); 374 valid("function x(i) { for (let i in {}) { } }"); 375 valid("function x(i) { for (let i of []) { } }"); 376 valid("function x(i) { for (let i of []) { } }"); 377 valid("function x(i) { for (let i; false; ) { } }"); 378 valid("let f = (i) => { for (let i in {}) { } }"); 379 valid("let f = (i) => { for (let i of []) { } }"); 380 valid("let f = (i) => { for (let i of []) { } }"); 381 valid("let f = (i) => { for (let i; false; ) { } }"); 382 valid("function* x(i) { for (let i in {}) { } }"); 383 valid("function* x(i) { for (let i of []) { } }"); 384 valid("function* x(i) { for (let i of []) { } }"); 385 valid("function* x(i) { for (let i; false; ) { } }"); 386 valid("function x(i) { for (const i in {}) { } }"); 387 valid("function x(i) { for (const i of []) { } }"); 388 valid("function x(i) { for (const i of []) { } }"); 389 valid("function x(i) { for (const i = 20; false; ) { } }"); 390 valid("let f = (i) => { for (const i in {}) { } }"); 391 valid("let f = (i) => { for (const i of []) { } }"); 392 valid("let f = (i) => { for (const i of []) { } }"); 393 valid("let f = (i) => { for (const i = 20; false; ) { } }"); 394 valid("function* x(i) { for (const i in {}) { } }"); 395 valid("function* x(i) { for (const i of []) { } }"); 396 valid("function* x(i) { for (const i of []) { } }"); 397 valid("function* x(i) { for (const i = 20; false; ) { } }"); 374 398 375 399 debug ("try statement"); -
trunk/Source/JavaScriptCore/ChangeLog
r217199 r217200 1 2017-05-21 Saam Barati <sbarati@apple.com> 2 3 We incorrectly throw a syntax error when declaring a top level for-loop iteration variable the same as a parameter 4 https://bugs.webkit.org/show_bug.cgi?id=171041 5 <rdar://problem/32082516> 6 7 Reviewed by Yusuke Suzuki. 8 9 We were treating a for-loop variable declaration potentially as a top 10 level statement, e.g, in a program like this: 11 ``` 12 function foo() { 13 for (let variable of expr) { } 14 } 15 ``` 16 But we should not be. This had the consequence of making this type of program 17 throw a syntax error: 18 ``` 19 function foo(arg) { 20 for (let arg of expr) { } 21 } 22 ``` 23 even though it should not. The fix is simple, we just need to increment the 24 statement depth before parsing anything inside the for loop. 25 26 * parser/Parser.cpp: 27 (JSC::Parser<LexerType>::parseForStatement): 28 1 29 2017-05-19 Yusuke Suzuki <utatane.tea@gmail.com> 2 30 -
trunk/Source/JavaScriptCore/parser/Parser.cpp
r216891 r217200 1134 1134 int startLine = tokenLine(); 1135 1135 next(); 1136 1137 DepthManager statementDepth(&m_statementDepth); 1138 m_statementDepth++; 1139 1136 1140 handleProductionOrFail(OPENPAREN, "(", "start", "for-loop header"); 1137 1141 int nonLHSCount = m_parserState.nonLHSCount;
Note: See TracChangeset
for help on using the changeset viewer.