archives

« Bugzilla Issues Index

#2855 — 19.2.1.1, 25.2.1.1: Don't set [[Strict]] for wrong function kind


19.2.1.1 Function ( p1, p2, … , pn, body )
25.2.1.1 GeneratorFunction (p1, p2, … , pn, body)

19.2.1.1 (and 25.2.1.1) set the [[Strict]] data slot already in step 16, this assignment should probably occur later. Currently it's possible to switch [[Strict]] using the wrong constructor function (while still leaving the function object uninitialized). Maybe move to 9.2.5 FunctionInitialize after step 4?


Test case:
---
let GeneratorFunction = (function*(){}).constructor;
let fn = Function[Symbol.create]();

function argumentsCaller(c) {
// See bug 2718
Object.defineProperty(arguments, "caller", {value: c});
return arguments.caller;
}

print(fn === argumentsCaller(fn)); // prints true

try { GeneratorFunction.call(fn, "'not strict'"); } catch (e) {}
print(fn === argumentsCaller(fn)); // prints true

try { GeneratorFunction.call(fn, "'use strict'"); } catch (e) {}
try {
argumentsCaller(fn);
} catch (e) {
// TypeError: "caller", "callee" and "arguments" are restricted properties in strict-mode
print(e);
}

try { GeneratorFunction.call(fn, "'not strict'"); } catch (e) {}
print(fn === argumentsCaller(fn)); // prints true
---


fixed in rev25 editor's draft


fixed in rev25 editor's draft