New ES6 constructor features and semantics: Alternative 1 auto allocation in derived classes

September 17, 2014 ยท View on GitHub

Summary of revised semantics for super based references

  1. The semantics of super used as the base for a property access (eg, super.name or super[expr] have not changed.
  2. Requires that a [[HomeObject]] has been set for the function, either via a concise method definition or dynamcially using toMethod.
  3. Starts property lookup at [[Prototype]] of [[HomeObject]] value.
  4. Passes current this value.
  5. super without a property access qualifier is only allowed within a constructor: function defined using a FunctionDeclaration, FunctionExpression, a call to the Function constructor, or the constructor ConciseMethod within a class defintion. It is also allowed within an ArrowFunction within the body of any such a function.
  6. In any other function, the occurrance of super without a property access qualifier is an early syntax error.
  7. This is a change. Previously an unqualifed super could occur any where and was implicitly a propety access using the [[MethodName]] value as the property key.
  8. Within a constructor an unqualifed super may only be used in one of these forms:
  9. NewExpression: new super
  10. NewExpression: new super Arguments
  11. CallExpression: super Arguments
  12. Within a constructor an unqualified super reference has the value of: currentFunction.[[GetPrototypeOf]](). This value is know as the "superclass constructor".
  13. Referencing the superclass constructor, when its value is null, throws a TypeError expression.
  14. A new super or new super Arguments expression invokes the superclass constructor's [[Construct]] internal method passing as the receiver argument, the current value of new^.
  15. A super Arguments expression invokes the superclass constructor's [[Call]] internal method passing the caller's this value as the this parameter.

There is a Rationale that further explains some of these design changes.