Changeset 179682 in webkit
- Timestamp:
- Feb 5, 2015, 12:58:38 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/js/parser-syntax-check-expected.txt (modified) (3 diffs)
-
LayoutTests/js/script-tests/parser-syntax-check.js (modified) (3 diffs)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/parser/Parser.cpp (modified) (4 diffs)
-
Source/JavaScriptCore/parser/Parser.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r179673 r179682 1 2015-02-05 Saam Barati <saambarati1@gmail.com> 2 3 Crash in uninitialized deconstructing variable. 4 https://bugs.webkit.org/show_bug.cgi?id=141070 5 6 Reviewed by Michael Saboff. 7 8 * js/parser-syntax-check-expected.txt: 9 * js/script-tests/parser-syntax-check.js: 10 1 11 2015-02-04 Brent Fulgham <bfulgham@apple.com> 2 12 -
trunk/LayoutTests/js/parser-syntax-check-expected.txt
r172380 r179682 679 679 PASS Valid: "for ({of} in of){}" with ReferenceError 680 680 PASS Valid: "function f() { for ({of} in of){} }" 681 PASS Invalid: "for (var of = x of of){}" 682 PASS Invalid: "function f() { for (var of = x of of){} }" 683 PASS Invalid: "for (var {of} = x of of){}" 684 PASS Invalid: "function f() { for (var {of} = x of of){} }" 685 PASS Invalid: "for (var [of] = x of of){}" 686 PASS Invalid: "function f() { for (var [of] = x of of){} }" 681 687 PASS Invalid: "for (of of of of){}" 682 688 PASS Invalid: "function f() { for (of of of of){} }" … … 766 772 PASS Valid: "var {1:x}=1" 767 773 PASS Valid: "function f() { var {1:x}=1 }" 774 PASS Valid: "var {x}=1" 775 PASS Valid: "function f() { var {x}=1 }" 776 PASS Valid: "var {x, y}=1" 777 PASS Valid: "function f() { var {x, y}=1 }" 778 PASS Valid: "var [x]=1" 779 PASS Valid: "function f() { var [x]=1 }" 780 PASS Valid: "var [x, y]=1" 781 PASS Valid: "function f() { var [x, y]=1 }" 768 782 PASS Valid: "[x]=1" 769 783 PASS Valid: "function f() { [x]=1 }" … … 788 802 PASS Valid: "({a:a}=1=1)" with ReferenceError 789 803 PASS Valid: "function f() { ({a:a}=1=1) }" 804 PASS Invalid: "var {x}" 805 PASS Invalid: "function f() { var {x} }" 806 PASS Invalid: "var {x, y}" 807 PASS Invalid: "function f() { var {x, y} }" 808 PASS Invalid: "var {x} = 20, {x, y}" 809 PASS Invalid: "function f() { var {x} = 20, {x, y} }" 810 PASS Invalid: "var {foo:bar, bar:baz}" 811 PASS Invalid: "function f() { var {foo:bar, bar:baz} }" 812 PASS Invalid: "var [x]" 813 PASS Invalid: "function f() { var [x] }" 814 PASS Invalid: "var [x, y]" 815 PASS Invalid: "function f() { var [x, y] }" 816 PASS Invalid: "var [x] = [], [x, y]" 817 PASS Invalid: "function f() { var [x] = [], [x, y] }" 790 818 PASS Invalid: "({get [x](){}})" 791 819 PASS Invalid: "function f() { ({get [x](){}}) }" -
trunk/LayoutTests/js/script-tests/parser-syntax-check.js
r172380 r179682 429 429 valid("for ([of] in of){}") 430 430 valid("for ({of} in of){}") 431 invalid("for (var of = x of of){}") 432 invalid("for (var {of} = x of of){}") 433 invalid("for (var [of] = x of of){}") 431 434 432 435 … … 476 479 valid("'use strict'; ({a: b}=null)") 477 480 valid("var {1:x}=1") 481 valid("var {x}=1") 482 valid("var {x, y}=1") 483 valid("var [x]=1") 484 valid("var [x, y]=1") 478 485 valid("[x]=1") 479 486 valid("var [x]=1") … … 487 494 valid("({a}=1=1)") 488 495 valid("({a:a}=1=1)") 496 invalid("var {x}") 497 invalid("var {x, y}") 498 invalid("var {x} = 20, {x, y}") 499 invalid("var {foo:bar, bar:baz}") 500 invalid("var [x]") 501 invalid("var [x, y]") 502 invalid("var [x] = [], [x, y]") 489 503 invalid("({get [x](){}})") 490 504 invalid("({set [x](){}})") -
trunk/Source/JavaScriptCore/ChangeLog
r179666 r179682 1 2015-02-05 Saam Barati <saambarati1@gmail.com> 2 3 Crash in uninitialized deconstructing variable. 4 https://bugs.webkit.org/show_bug.cgi?id=141070 5 6 Reviewed by Michael Saboff. 7 8 According to the ES6 spec, when a destructuring pattern occurs 9 as the left hand side of an assignment inside a var declaration 10 statement, the assignment must also have a right hand side value. 11 "var {x} = {};" is a legal syntactic statement, but, 12 "var {x};" is a syntactic error. 13 14 Section 13.2.2 of the latest draft ES6 spec specifies this requirement: 15 https://people.mozilla.org/~jorendorff/es6-draft.html#sec-variable-statement 16 17 * parser/Parser.cpp: 18 (JSC::Parser<LexerType>::parseVarDeclaration): 19 (JSC::Parser<LexerType>::parseVarDeclarationList): 20 (JSC::Parser<LexerType>::parseForStatement): 21 * parser/Parser.h: 22 1 23 2015-02-04 Gyuyoung Kim <gyuyoung.kim@samsung.com> 2 24 -
trunk/Source/JavaScriptCore/parser/Parser.cpp
r179371 r179682 379 379 TreeExpression scratch2 = 0; 380 380 JSTextPosition scratch3; 381 TreeExpression varDecls = parseVarDeclarationList(context, scratch, scratch1, scratch2, scratch3, scratch3, scratch3 );381 TreeExpression varDecls = parseVarDeclarationList(context, scratch, scratch1, scratch2, scratch3, scratch3, scratch3, VarDeclarationContext); 382 382 propagateError(); 383 383 failIfFalse(autoSemiColon(), "Expected ';' after var declaration"); … … 448 448 449 449 template <typename LexerType> 450 template <class TreeBuilder> TreeExpression Parser<LexerType>::parseVarDeclarationList(TreeBuilder& context, int& declarations, TreeDeconstructionPattern& lastPattern, TreeExpression& lastInitializer, JSTextPosition& identStart, JSTextPosition& initStart, JSTextPosition& initEnd )450 template <class TreeBuilder> TreeExpression Parser<LexerType>::parseVarDeclarationList(TreeBuilder& context, int& declarations, TreeDeconstructionPattern& lastPattern, TreeExpression& lastInitializer, JSTextPosition& identStart, JSTextPosition& initStart, JSTextPosition& initEnd, VarDeclarationListContext declarationListContext) 451 451 { 452 452 TreeExpression head = 0; … … 488 488 failIfFalse(pattern, "Cannot parse this deconstruction pattern"); 489 489 hasInitializer = match(EQUAL); 490 failIfTrue(declarationListContext == VarDeclarationContext && !hasInitializer, "Expected an initializer in destructuring variable declaration"); 490 491 lastPattern = pattern; 491 492 if (hasInitializer) { … … 736 737 JSTextPosition initStart; 737 738 JSTextPosition initEnd; 738 decls = parseVarDeclarationList(context, declarations, forInTarget, forInInitializer, declsStart, initStart, initEnd );739 decls = parseVarDeclarationList(context, declarations, forInTarget, forInInitializer, declsStart, initStart, initEnd, ForLoopContext); 739 740 m_allowsIn = true; 740 741 propagateError(); -
trunk/Source/JavaScriptCore/parser/Parser.h
r179371 r179682 743 743 template <class TreeBuilder> ALWAYS_INLINE TreeFunctionBody parseFunctionBody(TreeBuilder&); 744 744 template <class TreeBuilder> ALWAYS_INLINE TreeFormalParameterList parseFormalParameters(TreeBuilder&); 745 template <class TreeBuilder> TreeExpression parseVarDeclarationList(TreeBuilder&, int& declarations, TreeDeconstructionPattern& lastPattern, TreeExpression& lastInitializer, JSTextPosition& identStart, JSTextPosition& initStart, JSTextPosition& initEnd); 745 enum VarDeclarationListContext { ForLoopContext, VarDeclarationContext }; 746 template <class TreeBuilder> TreeExpression parseVarDeclarationList(TreeBuilder&, int& declarations, TreeDeconstructionPattern& lastPattern, TreeExpression& lastInitializer, JSTextPosition& identStart, JSTextPosition& initStart, JSTextPosition& initEnd, VarDeclarationListContext); 746 747 template <class TreeBuilder> NEVER_INLINE TreeConstDeclList parseConstDeclarationList(TreeBuilder&); 747 748
Note:
See TracChangeset
for help on using the changeset viewer.