Possible missing tests for legacy function properties #4340
Open
Description
opened on Dec 11, 2024
ECMA-262 specifies presence of "caller" and "arguments" properties on Function.prototype
that each use the single realm-global %ThrowTypeError% as both getter and setter, and does not specify such properties on function instances (where their absence is arguably expected). But, as observed at endojs/endo#2655 (comment) , implementations diverge.
- JSC and SM follow spec by defining them only on Function.prototype (but violate it by having distinct values for the 4 respective getter/setter functions).
- V8 violates the spec by additionally defining them on
Function()
and non-strictfunction(){…}
instances (non-writable and non-configurablenull
-valued data properties).- XS violates the spec by additionally defining
caller
[although correctly omittingarguments
] onFunction()
and non-strictfunction(){…}
instances (writable and configurableundefined
-valued data properties).- Hermes violates the spec by omitting them from Function.prototype, and additionally by defining them on strict
function(){…}
instances (non-configurable accessor properties with %ThrowTypeError% getter/setter functions).…
And Hermes has an additional bug: in a module context,function(){}
is treated differently fromfunction(){ "use strict"; }
(cf. Strict Mode Code, "Module code is always strict mode code") for both these function properties and for arguments.callee.
Activity