Changeset 198324 in webkit
- Timestamp:
- Mar 17, 2016 2:46:07 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r198309 r198324 1 2016-03-17 Skachkov Oleksandr <gskachkov@gmail.com> 2 3 Invoking super()/super inside of the eval should not lead to SyntaxError 4 https://bugs.webkit.org/show_bug.cgi?id=153864 5 6 Reviewed by Saam Barati. 7 8 * js/class-syntax-super-expected.txt: 9 * js/script-tests/class-syntax-super.js: 10 1 11 2016-03-16 Zalan Bujtas <zalan@apple.com> 2 12 -
trunk/LayoutTests/js/class-syntax-super-expected.txt
r194881 r198324 6 6 PASS (new Base) instanceof Base 7 7 PASS (new Derived) instanceof Derived 8 PASS (new DerivedWithEval) instanceof DerivedWithEval 9 PASS (new DerivedWithEval(true)):::ReferenceError: Cannot access uninitialized variable. 8 10 PASS (new Derived).callBaseMethod():::baseMethodValue 9 11 PASS x = (new Derived).callBaseMethod; x():::baseMethodValue … … 42 44 PASS function x() { super.method(); }:::SyntaxError: super can only be used in a method of a derived class. 43 45 PASS function x() { super(); }:::SyntaxError: Cannot call super() outside of a class constructor. 46 PASS eval("super.method()"):::SyntaxError: super is only valid inside functions. 47 PASS eval("super()"):::SyntaxError: super is only valid inside functions. 48 PASS (function () { eval("super.method()");})():::SyntaxError: super is only valid inside functions. 49 PASS (function () { eval("super()");})():::SyntaxError: super is only valid inside functions. 50 PASS new (class { constructor() { (function () { eval("super()");})(); } }):::SyntaxError: super is only valid inside functions. 51 PASS (new (class { method() { (function () { eval("super.method()");})(); }})).method():::SyntaxError: super is only valid inside functions. 44 52 PASS successfullyParsed 45 53 -
trunk/LayoutTests/js/script-tests/class-syntax-super.js
r194881 r198324 40 40 if (eval(s) === true) 41 41 testPassed(s); 42 else 42 else 43 43 testFailed(s); 44 44 } … … 47 47 if (eval(s) === false) 48 48 testPassed(s); 49 else 49 else 50 50 testFailed(s); 51 51 } … … 77 77 } 78 78 79 class DerivedWithEval extends Base { 80 constructor(throwTDZ) { 81 if (throwTDZ) 82 this.id = ''; 83 84 eval("super()"); 85 } 86 } 87 79 88 shouldBeTrue('(new Base) instanceof Base'); 80 89 shouldBeTrue('(new Derived) instanceof Derived'); 90 shouldBeTrue('(new DerivedWithEval) instanceof DerivedWithEval'); 91 shouldThrow('(new DerivedWithEval(true))', '"ReferenceError: Cannot access uninitialized variable."'); 81 92 shouldBe('(new Derived).callBaseMethod()', 'baseMethodValue'); 82 93 shouldBe('x = (new Derived).callBaseMethod; x()', 'baseMethodValue'); … … 116 127 shouldThrow('function x() { super.method(); }', '"SyntaxError: super can only be used in a method of a derived class."'); 117 128 shouldThrow('function x() { super(); }', '"SyntaxError: Cannot call super() outside of a class constructor."'); 129 shouldThrow('eval("super.method()")', '"SyntaxError: super is only valid inside functions."'); 130 shouldThrow('eval("super()")', '"SyntaxError: super is only valid inside functions."'); 131 132 shouldThrow('(function () { eval("super.method()");})()', '"SyntaxError: super is only valid inside functions."'); 133 shouldThrow('(function () { eval("super()");})()', '"SyntaxError: super is only valid inside functions."'); 134 135 shouldThrow('new (class { constructor() { (function () { eval("super()");})(); } })', '"SyntaxError: super is only valid inside functions."'); 136 shouldThrow('(new (class { method() { (function () { eval("super.method()");})(); }})).method()', '"SyntaxError: super is only valid inside functions."'); 118 137 119 138 var successfullyParsed = true; -
trunk/Source/JavaScriptCore/ChangeLog
r198296 r198324 1 2016-03-17 Skachkov Oleksandr <gskachkov@gmail.com> 2 3 Invoking super()/super inside of the eval should not lead to SyntaxError 4 https://bugs.webkit.org/show_bug.cgi?id=153864 5 6 Reviewed by Saam Barati. 7 8 Added support of the invoking super/super() inside of the eval within class. 9 Also support cases when eval is invoked in constructor, class method directly 10 or via arrow function. Access to the new.target in eval is not part of this patch 11 and will be implemented in https://bugs.webkit.org/show_bug.cgi?id=155545 12 13 * bytecompiler/BytecodeGenerator.cpp: 14 (JSC::BytecodeGenerator::BytecodeGenerator): 15 (JSC::BytecodeGenerator::emitLoadArrowFunctionLexicalEnvironment): 16 (JSC::BytecodeGenerator::isThisUsedInInnerArrowFunction): 17 (JSC::BytecodeGenerator::isNewTargetUsedInInnerArrowFunction): 18 (JSC::BytecodeGenerator::isSuperUsedInInnerArrowFunction): 19 (JSC::BytecodeGenerator::isSuperCallUsedInInnerArrowFunction): 20 (JSC::BytecodeGenerator::emitPutThisToArrowFunctionContextScope): 21 * interpreter/Interpreter.cpp: 22 (JSC::eval): 23 * parser/Parser.cpp: 24 (JSC::Parser<LexerType>::Parser): 25 (JSC::Parser<LexerType>::parseFunctionInfo): 26 (JSC::Parser<LexerType>::parseMemberExpression): 27 * parser/Parser.h: 28 (JSC::Scope::Scope): 29 (JSC::Scope::isEvalContext): 30 (JSC::Scope::setIsEvalContext): 31 (JSC::parse): 32 * runtime/CodeCache.cpp: 33 (JSC::CodeCache::getGlobalCodeBlock): 34 * tests/stress/arrowfunction-lexical-bind-supercall-4.js: 35 * tests/stress/arrowfunction-lexical-bind-superproperty.js: 36 * tests/stress/class-syntax-super-in-eval.js: Added. 37 * tests/stress/generator-with-super.js: 38 1 39 2016-03-15 Filip Pizlo <fpizlo@apple.com> 2 40 -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r198288 r198324 622 622 } 623 623 codeBlock->adoptVariables(variables); 624 625 if (evalNode->usesSuperCall() || evalNode->usesNewTarget()) 626 m_newTargetRegister = addVar(); 624 627 625 628 pushTDZVariables(*parentScopeTDZVariables, TDZCheckOptimization::DoNotOptimize); 626 627 if (codeBlock->isArrowFunctionContext() && evalNode->usesThis())629 630 if (codeBlock->isArrowFunctionContext() && (evalNode->usesThis() || evalNode->usesSuperProperty())) 628 631 emitLoadThisFromArrowFunctionLexicalEnvironment(); 629 632 630 if (needsToUpdateArrowFunctionContext() && !codeBlock->isArrowFunctionContext()) { 633 if (evalNode->usesSuperCall() || evalNode->usesNewTarget()) 634 emitLoadNewTargetFromArrowFunctionLexicalEnvironment(); 635 636 if (needsToUpdateArrowFunctionContext() && !codeBlock->isArrowFunctionContext() && !isDerivedConstructorContext()) { 631 637 initializeArrowFunctionContextScopeIfNeeded(); 632 638 emitPutThisToArrowFunctionContextScope(); … … 4103 4109 RegisterID* BytecodeGenerator::emitLoadArrowFunctionLexicalEnvironment(const Identifier& identifier) 4104 4110 { 4105 ASSERT(m_codeBlock->isArrowFunction() || m_codeBlock->isArrowFunctionContext() || constructorKind() == ConstructorKind::Derived );4111 ASSERT(m_codeBlock->isArrowFunction() || m_codeBlock->isArrowFunctionContext() || constructorKind() == ConstructorKind::Derived || m_codeType == EvalCode); 4106 4112 4107 4113 return emitResolveScope(nullptr, variable(identifier, ThisResolutionType::Scoped)); … … 4127 4133 } 4128 4134 4129 bool BytecodeGenerator::isThisUsedInInnerArrowFunction() 4135 bool BytecodeGenerator::isThisUsedInInnerArrowFunction() 4130 4136 { 4131 4137 return m_scopeNode->doAnyInnerArrowFunctionsUseThis() || m_scopeNode->doAnyInnerArrowFunctionsUseSuperProperty() || m_scopeNode->doAnyInnerArrowFunctionsUseSuperCall() || m_scopeNode->doAnyInnerArrowFunctionsUseEval() || m_codeBlock->usesEval(); … … 4139 4145 bool BytecodeGenerator::isNewTargetUsedInInnerArrowFunction() 4140 4146 { 4141 return m_scopeNode->doAnyInnerArrowFunctionsUseNewTarget() || m_scopeNode->doAnyInnerArrowFunctionsUseSuperCall() ;4147 return m_scopeNode->doAnyInnerArrowFunctionsUseNewTarget() || m_scopeNode->doAnyInnerArrowFunctionsUseSuperCall() || m_scopeNode->doAnyInnerArrowFunctionsUseEval() || m_codeBlock->usesEval(); 4142 4148 } 4143 4149 4144 4150 bool BytecodeGenerator::isSuperUsedInInnerArrowFunction() 4145 4151 { 4146 return m_scopeNode->doAnyInnerArrowFunctionsUseSuperCall() || m_scopeNode->doAnyInnerArrowFunctionsUseSuperProperty() ;4152 return m_scopeNode->doAnyInnerArrowFunctionsUseSuperCall() || m_scopeNode->doAnyInnerArrowFunctionsUseSuperProperty() || m_scopeNode->doAnyInnerArrowFunctionsUseEval() || m_codeBlock->usesEval(); 4147 4153 } 4148 4154 4149 4155 bool BytecodeGenerator::isSuperCallUsedInInnerArrowFunction() 4150 4156 { 4151 return m_scopeNode->doAnyInnerArrowFunctionsUseSuperCall() ;4157 return m_scopeNode->doAnyInnerArrowFunctionsUseSuperCall() || m_scopeNode->doAnyInnerArrowFunctionsUseEval() || m_codeBlock->usesEval(); 4152 4158 } 4153 4159 … … 4176 4182 void BytecodeGenerator::emitPutThisToArrowFunctionContextScope() 4177 4183 { 4178 if (isThisUsedInInnerArrowFunction() ) {4184 if (isThisUsedInInnerArrowFunction() || (m_scopeNode->usesSuperCall() && m_codeType == EvalCode)) { 4179 4185 ASSERT(isDerivedConstructorContext() || m_arrowFunctionContextLexicalEnvironmentRegister != nullptr); 4180 4186 -
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r198228 r198324 181 181 // If the literal parser bailed, it should not have thrown exceptions. 182 182 ASSERT(!callFrame->vm().exception()); 183 184 eval = callerCodeBlock->evalCodeCache().getSlow(callFrame, callerCodeBlock, callerCodeBlock->isStrictMode(), thisTDZMode, callerCodeBlock->unlinkedCodeBlock()->derivedContextType(), callerCodeBlock->unlinkedCodeBlock()->isArrowFunction(), sourceCode, callerScopeChain); 183 bool isInArrowFunctionContext = callerCodeBlock->unlinkedCodeBlock()->isArrowFunction() || callerCodeBlock->unlinkedCodeBlock()->isArrowFunctionContext(); 184 185 DerivedContextType derivedContextType = callerCodeBlock->unlinkedCodeBlock()->derivedContextType(); 186 187 if (!isInArrowFunctionContext && callerCodeBlock->unlinkedCodeBlock()->isClassContext()) { 188 derivedContextType = callerCodeBlock->unlinkedCodeBlock()->isConstructor() 189 ? DerivedContextType::DerivedConstructorContext 190 : DerivedContextType::DerivedMethodContext; 191 } 192 193 eval = callerCodeBlock->evalCodeCache().getSlow(callFrame, callerCodeBlock, callerCodeBlock->isStrictMode(), thisTDZMode, derivedContextType, isInArrowFunctionContext, sourceCode, callerScopeChain); 185 194 186 195 if (!eval) -
trunk/Source/JavaScriptCore/parser/Parser.cpp
r198233 r198324 193 193 194 194 template <typename LexerType> 195 Parser<LexerType>::Parser( 196 VM* vm, const SourceCode& source, JSParserBuiltinMode builtinMode, 197 JSParserStrictMode strictMode, SourceParseMode parseMode, SuperBinding superBinding, 198 ConstructorKind defaultConstructorKind, ThisTDZMode thisTDZMode) 195 Parser<LexerType>::Parser(VM* vm, const SourceCode& source, JSParserBuiltinMode builtinMode, JSParserStrictMode strictMode, SourceParseMode parseMode, SuperBinding superBinding, ConstructorKind defaultConstructorKind, ThisTDZMode thisTDZMode, DerivedContextType derivedContextType, bool isEvalContext) 199 196 : m_vm(vm) 200 197 , m_source(&source) … … 220 217 ScopeRef scope = pushScope(); 221 218 scope->setSourceParseMode(parseMode); 219 scope->setIsEvalContext(isEvalContext); 220 221 if (derivedContextType == DerivedContextType::DerivedConstructorContext) { 222 scope->setConstructorKind(ConstructorKind::Derived); 223 scope->setExpectedSuperBinding(SuperBinding::Needed); 224 } 225 226 if (derivedContextType == DerivedContextType::DerivedMethodContext) 227 scope->setExpectedSuperBinding(SuperBinding::Needed); 222 228 223 229 if (strictMode == JSParserStrictMode::Strict) … … 2068 2074 if (!m_lexer->isReparsingFunction()) { 2069 2075 if (functionScope->hasDirectSuper()) { 2070 ConstructorKind functionConstructorKind = functionBodyType == StandardFunctionBodyBlock 2076 ScopeRef scopeRef = closestParentOrdinaryFunctionNonLexicalScope(); 2077 ConstructorKind functionConstructorKind = functionBodyType == StandardFunctionBodyBlock && !scopeRef->isEvalContext() 2071 2078 ? constructorKind 2072 : closestParentOrdinaryFunctionNonLexicalScope()->constructorKind();2079 : scopeRef->constructorKind(); 2073 2080 semanticFailIfTrue(functionConstructorKind == ConstructorKind::None, "Cannot call super() outside of a class constructor"); 2074 2081 semanticFailIfTrue(functionConstructorKind != ConstructorKind::Derived, "Cannot call super() in a base class constructor"); 2075 2082 } 2076 2083 if (functionScope->needsSuperBinding()) { 2077 SuperBinding functionSuperBinding = functionBodyType == StandardFunctionBodyBlock 2084 ScopeRef scopeRef = closestParentOrdinaryFunctionNonLexicalScope(); 2085 SuperBinding functionSuperBinding = functionBodyType == StandardFunctionBodyBlock && !scopeRef->isEvalContext() 2078 2086 ? expectedSuperBinding 2079 : closestParentOrdinaryFunctionNonLexicalScope()->expectedSuperBinding();2087 : scopeRef->expectedSuperBinding(); 2080 2088 semanticFailIfTrue(functionSuperBinding == SuperBinding::NotNeeded, "super can only be used in a method of a derived class"); 2081 2089 } … … 3838 3846 3839 3847 if (baseIsSuper) { 3840 semanticFailIfFalse(currentScope()->isFunction(), "super is only valid inside functions"); 3848 ScopeRef scopeRef = closestParentOrdinaryFunctionNonLexicalScope(); 3849 // FIXME: Change error message for more suitable. https://bugs.webkit.org/show_bug.cgi?id=155491 3850 semanticFailIfFalse(currentScope()->isFunction() || (scopeRef->isEvalContext() && scopeRef->expectedSuperBinding() == SuperBinding::Needed), "super is only valid inside functions"); 3841 3851 base = context.createSuperExpr(location); 3842 3852 next(); -
trunk/Source/JavaScriptCore/parser/Parser.h
r197915 r198324 178 178 , m_isValidStrictMode(true) 179 179 , m_hasArguments(false) 180 , m_isEvalContext(false) 180 181 , m_constructorKind(static_cast<unsigned>(ConstructorKind::None)) 181 182 , m_expectedSuperBinding(static_cast<unsigned>(SuperBinding::NotNeeded)) … … 205 206 , m_isValidStrictMode(rhs.m_isValidStrictMode) 206 207 , m_hasArguments(rhs.m_hasArguments) 208 , m_isEvalContext(rhs.m_isEvalContext) 207 209 , m_constructorKind(rhs.m_constructorKind) 208 210 , m_expectedSuperBinding(rhs.m_expectedSuperBinding) … … 526 528 void setInnerArrowFunctionUsesNewTarget() { m_innerArrowFunctionFeatures |= NewTargetInnerArrowFunctionFeature; } 527 529 void setInnerArrowFunctionUsesArguments() { m_innerArrowFunctionFeatures |= ArgumentsInnerArrowFunctionFeature; } 530 531 bool isEvalContext() const { return m_isEvalContext; } 532 void setIsEvalContext(bool isEvalContext) { m_isEvalContext = isEvalContext; } 528 533 529 534 void setInnerArrowFunctionUsesEvalAndUseArgumentsIfNeeded() … … 708 713 bool m_isValidStrictMode : 1; 709 714 bool m_hasArguments : 1; 715 bool m_isEvalContext : 1; 710 716 unsigned m_constructorKind : 2; 711 717 unsigned m_expectedSuperBinding : 2; … … 764 770 765 771 public: 766 Parser( 767 VM*, const SourceCode&, JSParserBuiltinMode, JSParserStrictMode, SourceParseMode, SuperBinding, 768 ConstructorKind defaultConstructorKind = ConstructorKind::None, ThisTDZMode = ThisTDZMode::CheckIfNeeded); 772 Parser(VM*, const SourceCode&, JSParserBuiltinMode, JSParserStrictMode, SourceParseMode, SuperBinding, ConstructorKind defaultConstructorKind = ConstructorKind::None, ThisTDZMode = ThisTDZMode::CheckIfNeeded, DerivedContextType = DerivedContextType::None, bool isEvalContext = false); 769 773 ~Parser(); 770 774 … … 1529 1533 int m_numConstants; 1530 1534 ExpressionErrorClassifier* m_expressionErrorClassifier; 1535 bool m_isEvalContext; 1531 1536 1532 1537 struct DepthManager { … … 1647 1652 JSParserStrictMode strictMode, SourceParseMode parseMode, SuperBinding superBinding, 1648 1653 ParserError& error, JSTextPosition* positionBeforeLastNewline = nullptr, 1649 ConstructorKind defaultConstructorKind = ConstructorKind::None, 1650 ThisTDZMode thisTDZMode = ThisTDZMode::CheckIfNeeded)1654 ConstructorKind defaultConstructorKind = ConstructorKind::None, ThisTDZMode thisTDZMode = ThisTDZMode::CheckIfNeeded, 1655 DerivedContextType derivedContextType = DerivedContextType::None) 1651 1656 { 1652 1657 SamplingRegion samplingRegion("Parsing"); … … 1654 1659 ASSERT(!source.provider()->source().isNull()); 1655 1660 if (source.provider()->source().is8Bit()) { 1656 Parser<Lexer<LChar>> parser(vm, source, builtinMode, strictMode, parseMode, superBinding, defaultConstructorKind, thisTDZMode );1661 Parser<Lexer<LChar>> parser(vm, source, builtinMode, strictMode, parseMode, superBinding, defaultConstructorKind, thisTDZMode, derivedContextType, isEvalNode<ParsedNode>()); 1657 1662 std::unique_ptr<ParsedNode> result = parser.parse<ParsedNode>(error, name, parseMode); 1658 1663 if (positionBeforeLastNewline) … … 1665 1670 } 1666 1671 ASSERT_WITH_MESSAGE(defaultConstructorKind == ConstructorKind::None, "BuiltinExecutables::createDefaultConstructor should always use a 8-bit string"); 1667 Parser<Lexer<UChar>> parser(vm, source, builtinMode, strictMode, parseMode, superBinding, defaultConstructorKind, thisTDZMode );1672 Parser<Lexer<UChar>> parser(vm, source, builtinMode, strictMode, parseMode, superBinding, defaultConstructorKind, thisTDZMode, derivedContextType, isEvalNode<ParsedNode>()); 1668 1673 std::unique_ptr<ParsedNode> result = parser.parse<ParsedNode>(error, name, parseMode); 1669 1674 if (positionBeforeLastNewline) -
trunk/Source/JavaScriptCore/runtime/CodeCache.cpp
r197308 r198324 101 101 return unlinkedCodeBlock; 102 102 } 103 104 103 typedef typename CacheTypes<UnlinkedCodeBlockType>::RootNode RootNode; 104 DerivedContextType derivedContextType = executable->derivedContextType(); 105 105 std::unique_ptr<RootNode> rootNode = parse<RootNode>( 106 &vm, source, Identifier(), builtinMode, strictMode, 107 CacheTypes<UnlinkedCodeBlockType>::parseMode, SuperBinding::NotNeeded, error, nullptr, ConstructorKind::None, thisTDZMode); 106 &vm, source, Identifier(), builtinMode, strictMode, CacheTypes<UnlinkedCodeBlockType>::parseMode, SuperBinding::NotNeeded, error, nullptr, ConstructorKind::None, thisTDZMode, derivedContextType); 108 107 if (!rootNode) 109 108 return nullptr; -
trunk/Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-supercall-4.js
r197410 r198324 32 32 var arrow = () => eval('(() => super())()'); 33 33 arrow(); 34 return {}; 34 return { 35 value : 'constructor-value' 36 }; 35 37 } 36 38 }; … … 52 54 }; 53 55 54 // FIXME: Arrow function does not support using of eval with super/super() 55 // https://bugs.webkit.org/show_bug.cgi?id=153977 56 /* 56 57 57 for (var i=0; i < 1000; i++) { 58 58 new B(true); 59 59 var c = new C(); 60 testCase(typeof c.id, 'undefined', 'Error during set value in eval #1'); 60 testCase(c.value, 'constructor-value', 'Error during set value in eval #1.0'); 61 testCase(typeof c.id, 'undefined', 'Error during set value in eval #1.1'); 61 62 var d = new D(); 62 testCase(d.id, 'new-value', 'Error during set value in eval #2'); 63 testCase(d.idValue, testValue, 'Error during set value in eval #2.0'); 64 testCase(d.id, 'new-value', 'Error during set value in eval #2.1'); 63 65 var e = new E(); 64 testCase(e.id, 'new-value', 'Error during set value in eval #3'); 66 testCase(e.idValue, testValue, 'Error during set value in eval #3.0'); 67 testCase(e.id, 'new-value', 'Error during set value in eval #3.0'); 65 68 } 66 */67 69 68 var testException = function ( value, index) {70 var testException = function (Klass, value, index) { 69 71 var exception; 70 72 try { 71 new B(value);73 new Klass(value); 72 74 } catch (e) { 73 75 exception = e; … … 81 83 82 84 for (var i=0; i < 1000; i++) { 83 testException( false, i);85 testException(B, false, i); 84 86 } 85 87 … … 140 142 let h = new H(); 141 143 testCase(h.someValue, testValue, 'Error: not correct binding superProperty&this in constructor'); 144 145 class I extends A { 146 constructor (beforeSuper) { 147 if (beforeSuper) { 148 eval('(() => super())()'); 149 testCase(this.idValue, testValue, "Error: super() should create this and put value into idValue property"); 150 } else { 151 this.idValue = 'testValue'; 152 eval('(() => super())()'); 153 } 154 } 155 }; 156 157 let ic = new I(true); 158 testCase(ic.idValue, testValue, 'Error: not correct binding superProperty&this in constructor'); 159 160 for (var i=0; i < 1000; i++) { 161 testException(I, false, i); 162 } -
trunk/Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-superproperty.js
r197554 r198324 229 229 testCase(error, true, 'Error: using "super" property before super() should lead to error'); 230 230 } 231 232 class K extends A { 233 newMethodArrowEval() { 234 var arrow = () => eval('super.getValue()'); 235 var r = arrow(); 236 return r; 237 } 238 newMethodArrowDoubleEval() { 239 var arrow = () => eval("eval('super.getValue()')"); 240 var r = arrow(); 241 return r; 242 } 243 newMethodArrowEvalEvalArrow() { 244 var arrow = () => eval("eval('(() => super.getValue())()')"); 245 var r = arrow(); 246 return r; 247 } 248 newMethodArrowEvalEvalArrowEval() { 249 var arrow = () => eval("eval('(() => eval(\"super.getValue()\"))()')"); 250 var r = arrow(); 251 return r; 252 } 253 newMethodEval() { 254 var r = eval("super.getValue()"); 255 return r; 256 } 257 newMethodEvalEval() { 258 var r = eval("eval('super.getValue()')"); 259 return r; 260 } 261 newMethodEvalArrow() { 262 var r = eval("(() => super.getValue())()"); 263 return r; 264 } 265 newMethodEvalEvalArrow() { 266 var r = eval("eval('(() => super.getValue())()')"); 267 return r; 268 } 269 newMethodEvalEvalArrowEval() { 270 var r = eval("eval('(() => eval(\"(super.getValue())\"))()')"); 271 return r; 272 } 273 } 274 275 var k = new K(); 276 277 for (var i = 0; i < 1000; i++) { 278 testCase(k.newMethodArrowEval() , testValue, 'Error: Error in lexical bind with eval and arrow function #1'); 279 testCase(k.newMethodArrowDoubleEval() , testValue, 'Error: Error in lexical bind with eval and arrow function #2'); 280 testCase(k.newMethodArrowEvalEvalArrow() , testValue, 'Error: Error in lexical bind with eval and arrow function #3'); 281 testCase(k.newMethodArrowEvalEvalArrowEval() , testValue, 'Error: Error in lexical bind with eval and arrow function #4'); 282 283 testCase(k.newMethodEval() , testValue, 'Error: Error in lexical bind with eval and arrow function #5'); 284 testCase(k.newMethodEvalEval() , testValue, 'Error: Error in lexical bind with eval and arrow function #6'); 285 testCase(k.newMethodEvalArrow() , testValue, 'Error: Error in lexical bind with eval and arrow function #7'); 286 testCase(k.newMethodEvalEvalArrow() , testValue, 'Error: Error in lexical bind with eval and arrow function 8'); 287 testCase(k.newMethodEvalEvalArrowEval() , testValue, 'Error: Error in lexical bind with eval and arrow function #9'); 288 } -
trunk/Source/JavaScriptCore/tests/stress/generator-with-super.js
r192937 r198324 41 41 42 42 let a = new A(); 43 shouldThrow(() => { 44 a.gen().next(); 45 }, `SyntaxError: super is only valid inside functions.`); 43 shouldBe(a.gen().next().value, 42); 46 44 }()); 47 45
Note: See TracChangeset
for help on using the changeset viewer.