test262 icon indicating copy to clipboard operation
test262 copied to clipboard

Missing Coverage: InitializeInstanceElements happens before OrdinaryCallEvaluateBody

Open mgaudet opened this issue 4 years ago • 0 comments

In this bug we discovered some missing test262 coverage around [[Construct]], and the ordering therein.

I've got a skeleton of a test262 test below, but it may be incomplete. (I'm also having trouble verifying it runs... SpidermMonkey's test262 harness is mad at me at the moment, and I'm headed into vacation, so submitting as an issue for right now)

// Copyright (C) 2022 Matthew Gaudet. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget
description: InitializeInstanceElements happens before OrdinaryCallEvaluateBody(F, argumentsList)
info: |
  [...]
  6. If kind is base, then
    [...]
    b. Let initializeResult be Completion(InitializeInstanceElements(thisArgument, F)).
  [...]
  8. Let result be Completion(OrdinaryCallEvaluateBody(F, argumentsList)).
  [...]
features: [class]
---*/


class A {
  #x = 1
  y = 2
  constructor(a = this.#x, b = this.y) {
    assert.sameValue(a, 1, "Correctly read private field in parameters");
    assert.sameValue(b, 2, "Correctly read field in parameters");
  }
}

new A;

class X { };
class Y { };

let throwX = () => { throw new X; }
let throwY = () => { throw new Y; }

class B {
  x = "H" + throwX();
  constructor(o = throwY()) { }
};

assert.throws(X, function () { new B });

mgaudet avatar Mar 04 '22 22:03 mgaudet