instance-yield-expr-in-param.js (1076B)
1 // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 esid: sec-generatorfunction 5 description: Definition of instance `length` property 6 info: | 7 [...] 8 3. Return CreateDynamicFunction(C, NewTarget, "generator", args). 9 10 19.2.1.1.1 Runtime Semantics: CreateDynamicFunction 11 12 [...] 13 20. If kind is "generator", then 14 a. If parameters Contains YieldExpression is true, throw a SyntaxError 15 exception. 16 features: [generators] 17 ---*/ 18 19 var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor; 20 21 // YieldExpression is permitted in function body. 22 GeneratorFunction('x = yield'); 23 24 assert.throws(SyntaxError, function() { 25 GeneratorFunction('x = yield', ''); 26 }, 'YieldExpression not permitted generally'); 27 28 var withinGenerator = function*() { 29 GeneratorFunction('x = yield', ''); 30 }; 31 32 assert.throws(SyntaxError, function() { 33 withinGenerator().next(); 34 }, 'YieldExpression not permitted when calling context is a generator'); 35 36 reportCompare(0, 0);