Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normative: do not call super constructor when ThisBindingStatus is already initialized #762

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Commits on Jan 5, 2017

  1. Normative: do not call super constructor when ThisBindingStatus is al…

    …ready initialized
    
    Given:
    
    ```js
    class A { constructor() { print('a') } };
    class B extends A {
      constructor() {
        super();
        super();
      }
    }
    ```
    
    The current spec says 'a' is printed twice as the second super will
    invoke the super constructor before throwing an error due to `this`
    being initialized.
    
    This change throws just before invoking the super constructor if this
    has already been initialized. The argument list is evaluated as it
    may initialize `this` by invoking super (i.e. `super(super())`).
    
    Current implementations agree on the current spec behavior so it's
    questionable whether this change is worth doing. However this came up in
    real world code (due to a merge mishap) and caused significant confusion
    so if we can get away with changing it I think we should.
    bterlson committed Jan 5, 2017
    Configuration menu
    Copy the full SHA
    b660b68 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    eb17cb6 View commit details
    Browse the repository at this point in the history