Skip to content

Possible missing tests for legacy function properties #4340

Open
@gibson042

Description

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-strict function(){…} instances (non-writable and non-configurable null-valued data properties).
  • XS violates the spec by additionally defining caller [although correctly omitting arguments] on Function() and non-strict function(){…} instances (writable and configurable undefined-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 from function(){ "use strict"; } (cf. Strict Mode Code, "Module code is always strict mode code") for both these function properties and for arguments.callee.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions