[Edge 15/16][Suite.js] Class constructor cannot be called without the new keyword on subclassing
Opened this issue · 8 comments
On Edge 15.14986 with Suite.js
, "Class constructor cannot be called without the new keyword" error is thrown on subclassing. This should be a bug for Edge 15 prerelease build 14986.
Reproducible Code:
let example = Suite('example');
example.test = class ExampleSuite extends Suite {}
Workaround:
let example = Suite('example');
let t;
example.test = t = class ExampleSuite extends Suite {}
Non-reproducible Code:
class ExampleSuite extends Suite {}
Non-reproducible Code 2:
let example = Suite('example');
let tmp = class ExampleSuite extends Suite {}
example.test = tmp;
Reproducible with Edge 15.15002 as well.
With Edge 15.15063, the workaround above is ineffective because the ES6+ implementation is extremely unstable and cannot pass most of the test cases for scenarist. The real issues and the root causes have not been identified yet since it is too unstable. In contrast, ES5 is stable enough to pass all the tests.
It is disappointing that the version 15.15063 is seen as the RTM version of "Creators Update".
Reproducible script inserted into demo.js after registration of test classes
Note: Not reproducible if registration of test classes are removed
let Ac = (new Function('demo', 'return ' +
`(base) => class Ac extends base {
get description() { return 'AC'; }
async operation() {
await this.tap('AC');
this.history = this.state('AC');
}
async checkpoint() {
assert.equal(this.element.value, demo.expected[this.history], 'Value for scenario ' + this.history + ' is valid');
}
}`))({});
new (class E extends Ac(class B {}) {})()
Error in Edge 15.15063 - Note: Not reproducible earlier Edge 15 build 14***
SCRIPT5628: Multiple calls to 'super' in a class constructor are not allowed
Defined here https://github.com/Microsoft/ChakraCore/blob/master/lib/Parser/rterrors.h#L316
It seems super()
is implicitly called twice in the default constructor
.
Uncaught error outside test suite
‣
Error: Multiple calls to 'super' in a class constructor are not allowed
Ac at Function code:1
Number1 at Function code:1
Number2 at Function code:1
Plus at Function code:1
Number3 at Function code:1
Number4 at Function code:1
Equal at Function code:1
_12_Plus_34 at Function code:1
Anonymous function at index.html:27
Tentative Workaround for demo/src/demo.js
diff --git a/demo/src/demo.js b/demo/src/demo.js
index 0bc753b..d839f9d 100644
--- a/demo/src/demo.js
+++ b/demo/src/demo.js
@@ -98,6 +98,14 @@ class Connect extends DemoSuite {
(function (subclass, label) { // generate ES5 class by manipulating transpiled func.toString()
return 'return ' +
((base) => class __SUBCLASS__ extends base {
+ constructor(target) {
+ try {
+ super(target);
+ }
+ catch (e) {
+ this.target = target;
+ }
+ }
get description() { return '__LABEL__'; }
async operation() {
await this.tap('__LABEL__');
Reproducible with Edge 16.16215 as well