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 constructor code when there is code between prologue statements and super call #48765

Merged
merged 1 commit into from
Apr 19, 2022

Conversation

p-szm
Copy link
Contributor

@p-szm p-szm commented Apr 19, 2022

@ghost
Copy link

ghost commented Apr 19, 2022

CLA assistant check
All CLA requirements met.

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Apr 19, 2022
@@ -1146,7 +1146,7 @@ namespace ts {
[
...existingPrologue,
...prologue,
...(superStatementIndex <= existingPrologue.length ? emptyArray : visitNodes(constructor.body.statements, visitor, isStatement, existingPrologue.length, superStatementIndex)),
...(superStatementIndex <= existingPrologue.length ? emptyArray : visitNodes(constructor.body.statements, visitor, isStatement, existingPrologue.length, superStatementIndex - existingPrologue.length)),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The last argument is count and not end, so I believe the fix is to substract the start position from here. Otherwise we're processing too many nodes (including super())

Copy link
Member

Choose a reason for hiding this comment

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

Good catch!

@typescript-bot typescript-bot added For Milestone Bug PRs that fix a bug with a specific milestone and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Apr 19, 2022
@jakebailey jakebailey merged commit 2e619fd into microsoft:main Apr 19, 2022
@p-szm
Copy link
Contributor Author

p-szm commented Apr 19, 2022

@jakebailey any chance we can port this to 4.6.x? Maybe together with #48671 which is related. It's currently blocking my team from upgrading to 4.6.x

@jakebailey
Copy link
Member

Yes, I think both should be backported. @DanielRosenwasser

@jakebailey
Copy link
Member

@typescript-bot cherry-pick this to release-4.6

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 20, 2022

Heya @jakebailey, I've started to run the task to cherry-pick this into release-4.6 on this PR at 1b9a9d8. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

Hey @jakebailey, I've opened #48780 for you.

typescript-bot pushed a commit to typescript-bot/TypeScript that referenced this pull request Apr 20, 2022
Component commits:
1b9a9d8 Fix transformed constructor code when there is code between prologue statements and super call
Jack-Works pushed a commit to Jack-Works/TypeScript that referenced this pull request Apr 22, 2022
DanielRosenwasser pushed a commit that referenced this pull request May 3, 2022
Component commits:
1b9a9d8 Fix transformed constructor code when there is code between prologue statements and super call

Co-authored-by: Patrick Szmucer <pszmucer@palantir.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong constructor code generated when target is ES5
3 participants