Closed Bug 1157774 Opened 9 years ago Closed 9 years ago

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

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: rwaldron, Unassigned)

Details

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
Closed: 9 years ago
Resolution: --- → INVALID
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.