summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Object/constructor-return-undefined-throws.js
blob: ddf4ec4795cc7b8dfc1d5a343bc11b250ac69ff2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 9.2.2
description: Throws a ReferenceError if constructor result is undefined
info: |
  9.2.2 [[Construct]] ( argumentsList, newTarget)

  ...
  11. Let result be OrdinaryCallEvaluateBody(F, argumentsList).
  ...
  13. If result.[[type]] is return, then
    a. If Type(result.[[value]]) is Object, return
    NormalCompletion(result.[[value]]).
    ...
    c. If result.[[value]] is not undefined, throw a TypeError exception.
  ...
  15. Return envRec.GetThisBinding().

  8.1.1.3.4 GetThisBinding ()

  ...
  3. If envRec.[[thisBindingStatus]] is "uninitialized", throw a ReferenceError
  exception.
  ...

---*/

class Obj extends Object {
  constructor() {
    return undefined;
  }
}

class Obj2 extends Object {
  constructor() {}
}

assert.throws(ReferenceError, function() {
  new Obj();
});

assert.throws(ReferenceError, function() {
  new Obj2();
});

reportCompare(0, 0);