This repository has been archived by the owner. It is now read-only.

Don't set inType flag when parsing property names #266

Merged
merged 3 commits into from Jan 5, 2017

Conversation

Projects
None yet
4 participants
@vkurchatkin
Copy link
Contributor

vkurchatkin commented Dec 22, 2016

Q A
Bug fix? yes
Breaking change? no
New feature? no
Deprecations? no
Spec compliancy? yes
Tests added/pass? yes
Fixed tickets #264
License MIT

Previously inType flag was set when parsing property names. Among other things it was used to prevent jsx tokenization. This patch adds specialized inPropertyName flag and prevent jsx tokenization in jsx plugin.

@xtuc xtuc self-requested a review Dec 24, 2016

@xtuc

xtuc approved these changes Dec 24, 2016

@@ -0,0 +1,3 @@
const map = {
[age <= 17] : 'Too young'

This comment has been minimized.

@xtuc

xtuc Dec 24, 2016

Member

Do we need the original use case? It's not important in the expected AST.

I would suggest something like that:

[1 <= 0]: null
@@ -16,6 +16,7 @@ export default class State {
this.inFunction =
this.inGenerator =
this.inAsync =
this.inPropertyName =

This comment has been minimized.

@danez

danez Dec 24, 2016

Member

Can you please also add the flow type, like the other fields?

This comment has been minimized.

@xtuc

xtuc Dec 26, 2016

Member

I did it in 1d5932c

@danez
Copy link
Member

danez left a comment

I haven't tested, but I think that this won't work anymore now:

var x = {
  [<div></div>]: 0
}

This is not really useful, but should be still valid.

Although just noticed it is not working in 6.13 either.

@@ -416,6 +416,10 @@ export default function(instance) {
return function(code) {
let context = this.curContext();

if (this.state.inPropertyName) {
return inner.call(this, code);
}

This comment has been minimized.

@danez

danez Dec 24, 2016

Member

We could move this before the curContext() call.

xtuc and others added some commits Dec 26, 2016

Daniel Tschinder

@danez danez merged commit 3267e5f into babel:master Jan 5, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@hzoo hzoo referenced this pull request Mar 1, 2017

Closed

Parsing error since 7.1.1 #428

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.