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 emitting super-call when using prologue directives #6911

Merged
merged 4 commits into from
Feb 5, 2016
Merged

Conversation

yuit
Copy link
Contributor

@yuit yuit commented Feb 4, 2016

Fix #6901

@DanielRosenwasser DanielRosenwasser changed the title Fix emitting super-call when using prolongDirectives Fix emitting super-call when using prologueDirectives Feb 4, 2016
@DanielRosenwasser DanielRosenwasser changed the title Fix emitting super-call when using prologueDirectives Fix emitting super-call when using prologue directives Feb 4, 2016
* @param ctor constructor declaration
* @param index an index to constructor's body to check
*/
function getSuperCallAtGivenIndex(ctor: ConstructorDeclaration, index: number): ExpressionStatement {
Copy link
Member

Choose a reason for hiding this comment

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

I'd just take a NodeArray<Statement>

Copy link
Member

Choose a reason for hiding this comment

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

Can you add an explicit return at the end?

Copy link
Member

Choose a reason for hiding this comment

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

Why doesn't this just return a boolean if there's a super call at that index?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't just return boolean because we should the super-call found here for emitting later

@DanielRosenwasser
Copy link
Member

Is it guaranteed that the initial super call will be an expression statement? Is it not possible to have the following?

1 && super()

@mhegazy
Copy link
Contributor

mhegazy commented Feb 4, 2016

yes, otherwise we error. we only skip prologues (e.g. "use strict").

@mhegazy
Copy link
Contributor

mhegazy commented Feb 4, 2016

👍

@mhegazy
Copy link
Contributor

mhegazy commented Feb 4, 2016

please port to master as well.

@yuit
Copy link
Contributor Author

yuit commented Feb 5, 2016

@DanielRosenwasser yep it will an error. There is a discussion/issue whether we should allow that :) #6908

yuit added a commit that referenced this pull request Feb 5, 2016
Fix emitting super-call when using prologue directives
@yuit yuit merged commit aaea852 into release-1.8 Feb 5, 2016
@yuit yuit deleted the fix6901 branch February 5, 2016 05:12
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants