Skip to content

babylon: throw parse error if class properties do not have a semico…#3225

Merged
sebmck merged 1 commit intobabel:masterfrom
hzoo:cp-semi
Jan 6, 2016
Merged

babylon: throw parse error if class properties do not have a semico…#3225
sebmck merged 1 commit intobabel:masterfrom
hzoo:cp-semi

Conversation

@hzoo
Copy link
Member

@hzoo hzoo commented Dec 30, 2015

…lon (fixes T6873)

Fixes https://phabricator.babeljs.io/T6873.
Ref tc39/proposal-class-public-fields#25

not using isLineTerminator since it tries to eat the semicolon

// TODO
pp.isLineTerminator = function () {
  return this.eat(tt.semi) || this.canInsertSemicolon();
};

@codecov-io
Copy link

Current coverage is 84.94%

Merging #3225 into master will decrease coverage by -0.22% as of 976edfc

@@            master   #3225   diff @@
======================================
  Files          215     215       
  Stmts        15653   15654     +1
  Branches      3353    3354     +1
  Methods          0       0       
======================================
- Hit          13331   13298    -33
- Partial        678     712    +34
  Missed        1644    1644       

Review entire Coverage Diff as of 976edfc

Powered by Codecov. Updated on successful CI builds.

@jamiebuilds
Copy link
Contributor

This is an interesting one, it's kind of a breaking change, but also for spec compliance. How should we handle it?

@jmm
Copy link
Member

jmm commented Dec 30, 2015

@thejameskyle I think in general spec-compliance failures are bugs and correcting them should be versioned as such. People need to figure out correct syntax (e.g. by consulting the spec / articles [though those can have errors] / discussions) as opposed to having an expectation that Babel interpreting it a certain way validates it and that's a contract to continue interpreting it that way. In other words, if the syntax was broken in the first place I don't think Babel should be responsible for not "breaking" it by fixing its interpretation.

I think it's going to be problematic to have to bump the major version to do spec conformance fixes, especially if plugin and core component versions move in parallel.

And of course this syntax isn't even standardized yet so should be seen as experimental and unstable even if you do follow its "spec". Not entirely sure what versioning scheme makes sense for that.

@jamiebuilds
Copy link
Contributor

Yeah but again this was supposed to be one of the benefits of splitting everything up into plugins, they could be versioned properly even through spec compliance chances.

@jmm
Copy link
Member

jmm commented Dec 31, 2015

@thejameskyle yeah I'm not arguing against that (from your recent comment I actually thought you came down in favor of maintaining the single version line), but what is the proper versioning (and is it different for standardized stuff vs. proposals)?

Is every spec compliance fix going to be considered a breaking change? Perhaps that actually makes more sense for proposals, but if incorrect interpretation of standardized stuff is corrected is that not a bug fix? I'm not being a troll, I just need to understand (and collectively perhaps we need to figure it out, if I'm not the only one who's uncertain).

What about #3220, is that a breaking change in Babylon? (To me it's a bug fix.)

On another note (not a spec-compliance issue), #3176 could break people's stuff if they were relying on the old behavior, but I interpreted it as a bug fix (and I think it would be insane to bump the major of everything -- babel-core etc. -- to change it).

@jamiebuilds
Copy link
Contributor

Idk, if this were a spec compliance change in a plugin, I would favor bumping on any breaking change, but since its in the parser we'd have to bump everything (babel-core, etc), so idk. I guess this isn't that significant of a change.

hzoo referenced this pull request Jan 2, 2016
Defer to the built-in `typeof` if support for symbols exists.
@hzoo hzoo added the parser label Jan 4, 2016
sebmck added a commit that referenced this pull request Jan 6, 2016
`babylon`: throw parse error if class properties do not have a semico…
@sebmck sebmck merged commit d2f5a40 into babel:master Jan 6, 2016
@sebmck
Copy link
Contributor

sebmck commented Jan 6, 2016

Semver is very inadequate for a compiler/parser. I'd say this is fixing a bug since we weren't following the specification.

yannickcr added a commit to jsx-eslint/eslint-plugin-react that referenced this pull request Jan 6, 2016
@hzoo
Copy link
Member Author

hzoo commented Jan 7, 2016

should of cc @jeffmo to be sure (obvious in hindsight)

@jeffmo
Copy link
Contributor

jeffmo commented Jan 7, 2016

Woo! Thanks for fixing this :)

Macroz added a commit to HSLdevcom/digitransit-ui that referenced this pull request Jan 7, 2016
Babel 6.4 changed compliance to require semicolons for class properties.

babel/babel#3225
@hzoo
Copy link
Member Author

hzoo commented Jan 7, 2016

Can use jscs to autofix if necessary. Made a simple PR jscs-dev/node-jscs#2057.

Instructions: https://gist.github.com/hzoo/cc8af2132d1775d8511d

@mgcrea
Copy link

mgcrea commented Jan 7, 2016

Just stumbled accross this, why do we need to throw an error here while it is optional everywhere else? Does the spec is really that strict (should crash if no semicolon)? Shouldn't this be a linting issue?

@hzoo
Copy link
Member Author

hzoo commented Jan 7, 2016

Yeah I thought it was a linting issue initially as well - in the OP https://phabricator.babeljs.io/T6873

@jmm
Copy link
Member

jmm commented Jan 7, 2016

@mgcrea Did you check out the reference link in the OP?

@mgcrea
Copy link

mgcrea commented Jan 7, 2016

Nop, but I should have! I got it.

@dylanpyle
Copy link

I'll add my +1 for the "this broke our builds and took me by surprise". I do agree that a spec-compliance issue is more of a bugfix than anything else, but is there a better way to call these out in future? Maybe introducing a transition version with a loud (but non-breaking) deprecation warning?

@hzoo
Copy link
Member Author

hzoo commented Jan 7, 2016

@dylanpyle Yeah we can definitely try making it easier to transition. Sorry about that, we will add a deprecation message for future breaking changes in the parser and figure that process out..

For this particular issue, you can use my jscs branch to autofix the semicolons if that's helpful which I mentioned above #3225 (comment).

@AndrewIngram
Copy link

FWIW, this hit me too, and all my dependencies are pinned to exact versions. Code that was working fine locally failed in staging, I was only able to reproduce locally by blowing away my node_modules and installing fresh. I'd have been able to avoid this if i'd been using shrinkwrap. However, I should add that my mistaken use of a semicolon here from mimicking widespread examples of using class properties.

@flying-sheep
Copy link

time to revert this! tc39/proposal-class-public-fields#26 (comment)

@ziemkowski
Copy link

@kittens is this something you plan to take care of or should one of us submit a pull request backing this out? I'd just do it but that seems like poor etiquette.

@flying-sheep
Copy link

@ziemkowski this is the bug for it (title is worded a bit strangely).

@jmm
Copy link
Member

jmm commented Feb 3, 2016

@flying-sheep

I will follow up with Babel and to get this fixed so that ASI works as expected there.

tc39/proposal-class-public-fields#26 (comment)

@hzoo
Copy link
Member Author

hzoo commented Feb 7, 2016

We'll do a PR reverting the commits shortly (I made another commit after this fixing error location)

@ChrisCinelli
Copy link

@hzoo? Do you have an eta? End of this week?
We need to move to Babel 6 for another feature but this one is holding us back.

@hzoo
Copy link
Member Author

hzoo commented Feb 10, 2016

Not sure, I put what we want to get in https://github.com/babel/babel/milestones/6.5.x - maybe this weekend? #3332

enykeev added a commit to StackStorm/st2flow that referenced this pull request Feb 11, 2016
```TypeError: Cannot read property 'visitClass' of undefined```

Also, due to babel/babel#3225, linter now complains on the absence of `;` at the end of class definition. The decision was reverted, but the change itself is still pending. For now, just ignore the error.
@hzoo
Copy link
Member Author

hzoo commented Feb 12, 2016

@flying-sheep
Copy link

cool stuff!

@hzoo hzoo deleted the cp-semi branch February 25, 2017 17:29
JacopKane pushed a commit to JacopKane/babel that referenced this pull request Jan 11, 2018
`babylon`: throw parse error if class properties do not have a semico…
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 6, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.