Changeset 194153 in webkit
- Timestamp:
- Dec 16, 2015 9:49:14 AM (8 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r194144 r194153 1 2015-12-16 Caitlin Potter <caitp@igalia.com> 2 3 [JSC] fix error message for eval/arguments CoverInitializedName in strict code 4 https://bugs.webkit.org/show_bug.cgi?id=152304 5 6 Reviewed by Darin Adler. 7 8 Because the error was originally classified as indicating a Pattern, the 9 error in AssignmentPattern parsing causes the reported message to revert to 10 the original Expression error message, which in this case is incorrect. 11 12 This change modifies the implementation of the strict code 13 error slightly, and reclassifies the error to prevent the message revert, 14 which improves the clarity of the message overall. 15 16 * parser/Parser.cpp: 17 (JSC::Parser<LexerType>::parseAssignmentElement): 18 (JSC::Parser<LexerType>::parseDestructuringPattern): 19 * parser/Parser.h: 20 (JSC::Parser::ExpressionErrorClassifier::reclassifyExpressionError): 21 (JSC::Parser::reclassifyExpressionError): 22 * tests/stress/destructuring-assignment-syntax.js: 23 1 24 2015-12-16 Joseph Pecoraro <pecoraro@apple.com> 2 25 -
trunk/Source/JavaScriptCore/parser/Parser.cpp
r194107 r194153 844 844 845 845 if (strictMode() && m_lastIdentifier && context.isResolve(element)) { 846 failIfTrueIfStrict(m_vm->propertyNames->eval == *m_lastIdentifier, "Cannot modify 'eval' in strict mode");847 failIfTrueIfStrict( m_vm->propertyNames->arguments == *m_lastIdentifier, "Cannot modify 'arguments' in strict mode");846 bool isEvalOrArguments = m_vm->propertyNames->eval == *m_lastIdentifier || m_vm->propertyNames->arguments == *m_lastIdentifier; 847 failIfTrueIfStrict(isEvalOrArguments, "Cannot modify '", m_lastIdentifier->impl(), "' in strict mode"); 848 848 } 849 849 … … 932 932 innerPattern = parseBindingOrAssignmentElement(context, kind, exportType, duplicateIdentifier, hasDestructuringPattern, bindingContext, depth + 1); 933 933 else { 934 if (kind == DestructureToExpressions && strictMode()) { 935 failIfTrueIfStrict(m_vm->propertyNames->eval == *propertyName, "Cannot modify 'eval' in strict mode"); 936 failIfTrueIfStrict(m_vm->propertyNames->arguments == *propertyName, "Cannot modify 'arguments' in strict mode"); 934 if (kind == DestructureToExpressions) { 935 bool isEvalOrArguments = m_vm->propertyNames->eval == *propertyName || m_vm->propertyNames->arguments == *propertyName; 936 if (isEvalOrArguments && strictMode()) 937 reclassifyExpressionError(ErrorIndicatesPattern, ErrorIndicatesNothing); 938 failIfTrueIfStrict(isEvalOrArguments, "Cannot modify '", propertyName->impl(), "' in strict mode"); 937 939 } 938 940 innerPattern = createBindingPattern(context, kind, exportType, *propertyName, identifierToken, bindingContext, duplicateIdentifier); -
trunk/Source/JavaScriptCore/parser/Parser.h
r194017 r194153 765 765 } 766 766 767 void reclassifyExpressionError(ExpressionErrorClass oldClassification, ExpressionErrorClass classification) 768 { 769 if (m_class != oldClassification) 770 return; 771 m_class = classification; 772 } 773 767 774 void propagateExpressionErrorClass() 768 775 { … … 783 790 if (m_expressionErrorClassifier) 784 791 m_expressionErrorClassifier->classifyExpressionError(classification); 792 } 793 794 ALWAYS_INLINE void reclassifyExpressionError(ExpressionErrorClass oldClassification, ExpressionErrorClass classification) 795 { 796 if (m_expressionErrorClassifier) 797 m_expressionErrorClassifier->reclassifyExpressionError(oldClassification, classification); 785 798 } 786 799 -
trunk/Source/JavaScriptCore/tests/stress/destructuring-assignment-syntax.js
r194107 r194153 60 60 61 61 testSyntaxError("'use strict'; ({ eval } = {})", "SyntaxError: Cannot modify 'eval' in strict mode."); 62 // FIXME: support CoverInitializedName properly. 63 //testSyntaxError("'use strict'; ({ eval = 0 } = {})", "SyntaxError: Cannot modify 'eval' in strict mode."); 62 testSyntaxError("'use strict'; ({ eval = 0 } = {})", "SyntaxError: Cannot modify 'eval' in strict mode."); 64 63 testSyntaxError("'use strict'; ({ a: eval } = {})", "SyntaxError: Cannot modify 'eval' in strict mode."); 65 64 testSyntaxError("'use strict'; ({ a: eval = 0 } = {})", "SyntaxError: Cannot modify 'eval' in strict mode."); 66 65 testSyntaxError("'use strict'; ({ arguments } = {})", "SyntaxError: Cannot modify 'arguments' in strict mode."); 67 // FIXME: support CoverInitializedName properly. 68 //testSyntaxError("'use strict'; ({ arguments = 0 } = {})", "SyntaxError: Cannot modify 'arguments' in strict mode."); 66 testSyntaxError("'use strict'; ({ arguments = 0 } = {})", "SyntaxError: Cannot modify 'arguments' in strict mode."); 69 67 testSyntaxError("'use strict'; ({ a: arguments } = {})", "SyntaxError: Cannot modify 'arguments' in strict mode."); 70 68 testSyntaxError("'use strict'; ({ a: arguments = 0 } = {})", "SyntaxError: Cannot modify 'arguments' in strict mode.");
Note: See TracChangeset
for help on using the changeset viewer.