Skip to content

parse/check/emit shorthand property assignment in destructuring#5121

Merged
vladima merged 2 commits into
masterfrom
shorthandPropsInDestructuring
Oct 11, 2015
Merged

parse/check/emit shorthand property assignment in destructuring#5121
vladima merged 2 commits into
masterfrom
shorthandPropsInDestructuring

Conversation

@vladima
Copy link
Copy Markdown
Contributor

@vladima vladima commented Oct 5, 2015

fixes #5035

Comment thread src/compiler/types.ts
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When would you have a question token in a shorthand?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

AFAIR we currently parse it and issue the grammar error later

@JsonFreeman
Copy link
Copy Markdown
Contributor

Looks good, but probably someone on the team should sign off.

@vladima
Copy link
Copy Markdown
Contributor Author

vladima commented Oct 9, 2015

Thanks @JsonFreeman :)

@vladima
Copy link
Copy Markdown
Contributor Author

vladima commented Oct 10, 2015

@mhegazy can you take a look?

@DanielRosenwasser
Copy link
Copy Markdown
Member

I actually posted comments earlier, but GitHub went down as I was posting them. Sorry about that @vladima

Comment thread src/compiler/types.ts
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not just error on the objectAssignmentInitializer?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the idea is to error on the first incorrect token. Also, this controls the span size so it is just 1.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the comment is referring to both equalsToken and objectAssignmentInitializer - this pair matches Initializer part from CoverInitializerName production. My reasoning of reporting error on = instead of entire range [equalsToken, objectAssignmentInitializer] was:

  • having large ranges of squigglies is annoying
  • I can certainly see cases when by mistake people type {x = 1} instead of {x: 1} and personally for me it will look confusing if we squiggle = 1 instead of just =`

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, @JsonFreeman is right

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Okay; in that case, can you amend the comment so it specifically says "The below are used". and just make it "It is a grammar error".

Other than that LGTM.

vladima added a commit that referenced this pull request Oct 11, 2015
parse/check/emit shorthand property assignment in destructuring
@vladima vladima merged commit 1b5dc0d into master Oct 11, 2015
@vladima vladima deleted the shorthandPropsInDestructuring branch October 11, 2015 05:39
vladima added a commit that referenced this pull request Oct 11, 2015
parse/check/emit shorthand property assignment in destructuring
@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.

Incorrectly parsed object destructuring assignment with short-hand properties

4 participants