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

Fix parsing of nested class with constructor #246

Merged
merged 1 commit into from May 12, 2023

Conversation

DimaIT
Copy link
Contributor

@DimaIT DimaIT commented May 10, 2023

Fixes the issue described below by remembering the HasConstructor flag and restoring it after parsing the class body.


Meriyah fails to parse the following code:

new class {
  start() {
    new class {
      constructor() {}
    }
  }

  constructor() {}          
}

Seems that the position of the outer constructor is what causes the problem cause when the outer constructor is above the start method Meriyah can parse it.

This snippet succeeds

new class {
  constructor() {}          

  start() {
    new class {
      constructor() {}
    }
  }
}

Copy link
Member

@3cp 3cp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx!

@3cp
Copy link
Member

3cp commented May 10, 2023

It lets me to think: to deal with similar nested situations, a stack of flags/context might be better.

@3cp
Copy link
Member

3cp commented May 10, 2023

There are some minor issues in unit tests to be fixed, missing "decorators": [] in various places.

Co-authored-by: DimaIT <dima@surfly.com>
@DimaIT
Copy link
Contributor Author

DimaIT commented May 11, 2023

There are some minor issues in unit tests to be fixed, missing "decorators": [] in various places.

Fixed and added a couple more tests.

@3cp 3cp merged commit 8f7124b into meriyah:master May 12, 2023
3 checks passed
@3cp
Copy link
Member

3cp commented May 12, 2023

Thx!
v4.3.7 is released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants