Set.prototype.forEach default "this" should be undefined, not global object

RESOLVED INVALID

Status

()

Core
JavaScript Engine
RESOLVED INVALID
3 years ago
3 years ago

People

(Reporter: rwaldron, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

3 years ago
Replicate with: 

  var s = new Set([1]);

  s.forEach(function() {
    console.log(this === undefined);
  });


Actual: false

Expect: true



The value of `this` is incorrectly the global object: 

23.2.3.6 Set.prototype.forEach ( callbackfn [ , thisArg ] ) https://people.mozilla.org/~jorendorff/es6-draft.html#sec-set.prototype.foreach


...
5. If thisArg was supplied, let T be thisArg; else let T be undefined.
...
Well boxing happens on the callee site, and this is not a strict function.
*side!!!!!
Status: NEW → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → INVALID
(Reporter)

Comment 3

3 years ago
For reference, the rationale for filing the bug was a result of reading: 

9.3.1 [[Call]] ( thisArgument, argumentsList) https://people.mozilla.org/~jorendorff/es6-draft.html#sec-built-in-function-objects-call-thisargument-argumentslist


When I should've been reading: 

9.2.1 [[Call]] ( thisArgument, argumentsList) https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-function-objects-call-thisargument-argumentslist
You need to log in before you can comment on or make changes to this bug.