« Bugzilla Issues Index

#1537 — FunctionInitialize should set internal properties after user-modifiable properties

FunctionInitialize does not take into account that "length", "caller" or "arguments" may be already present on the function object. To avoid undefined behaviour or for example strict-mode functions without poisoned "caller" properties etc., I'd suggest to:

(1) Make steps 12-13 the initial steps of FunctionInitialize
(2) Change [[DefineOwnProperty]] to DefinePropertyOrThrow()

This is similar to the String constructor which sets internal properties after user-modifiable properties.

Test case for strict-mode function object without poisoned "caller" property:

$ ./src/main/bin/ --strict
js> class Fn extends Function{ constructor(){} }
js> f = new Fn(), Object.defineProperty(f, "caller", {value: null})
function F() { /* source not available */ }
js>, "'use strict'")
function anonymous () {
'use strict'
js> Object.getOwnPropertyDescriptor(f, "caller")

fixed in rev 16 editor's draft

fixed in rev16 draft. July 15, 2013