All of the new constructors, Map, Set, WeakMap and WeakSet should fail
when called as a function unless `this` already has a certain internal
property, ie [[MapData]]. This is so that sub classing works as
expected.

However, all JS engines that supports Map, Set and WeakMap are future
hostile and they all return a new instance when called as a function.
For example, here is the V8 code:

function MapConstructor() {
  if (%_IsConstructCall()) {
    %MapInitialize(this);
  } else {
    return new $Map();
  }
}

I understand that fully supporting @@create requires a lot of work but
until then we should at least throw when called as function to allow
us to get out of this mess eventually.

--
erik
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to