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

[parser] Better error message for missing number exponent #12072

Merged
merged 3 commits into from Oct 14, 2020
Merged

[parser] Better error message for missing number exponent #12072

merged 3 commits into from Oct 14, 2020

Conversation

iamfotx
Copy link
Contributor

@iamfotx iamfotx commented Sep 17, 2020

fix(babel-parser) better error message for missing number exponent

Q                       A
Fixed Issues? Fixes #12071
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

@@ -71,6 +71,8 @@ export const ErrorMessages = Object.freeze({
InvalidLhs: "Invalid left-hand side in %0",
InvalidLhsBinding: "Binding invalid left-hand side in %0",
InvalidNumber: "Invalid number",
InvalidOrMissingExponent:
"Invalid or Missing exponent after 'e' in floating-point number",
Copy link
Member

Choose a reason for hiding this comment

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

Thanks! Could you just make this lowercase? (don't use GH's "Apply changes" button because you need to regenerate the tests locally)

Suggested change
"Invalid or Missing exponent after 'e' in floating-point number",
"Invalid or missing exponent after 'e' in floating-point number",

Copy link
Member

Choose a reason for hiding this comment

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

Or maybe just delete "Invalid or", I don't have a preference in either direction.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I think we can drop "Invalid or" or:

"Floating-point numbers require a valid exponent after the 'e'."

Copy link
Contributor Author

@iamfotx iamfotx Sep 17, 2020

Choose a reason for hiding this comment

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

@nicolo-ribaudo , what do you think if I work around and throw accordingly by figuring out if it is actually missing or invalid?

For example: 3ea would also throw with the same error message. I would consider, it (3ea) is invalid, that's why I used "invalid"...

@nicolo-ribaudo nicolo-ribaudo added area: errors pkg: parser PR: Polish 💅 A type of pull request used for our changelog categories labels Sep 17, 2020
@babel-bot
Copy link
Collaborator

babel-bot commented Sep 17, 2020

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/29948/

@codesandbox-ci
Copy link

codesandbox-ci bot commented Sep 17, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 4d5ef93:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

nicolo-ribaudo
nicolo-ribaudo previously approved these changes Oct 2, 2020
@existentialism
Copy link
Member

I still prefer:

"Floating-point numbers require a valid exponent after the 'e'."

@nicolo-ribaudo nicolo-ribaudo dismissed their stale review October 2, 2020 14:51

Whops, GH is collapsing the inline discussion and I didn't remember about it 😅

@kaicataldo
Copy link
Member

@iamfotx Anything we can do to help get this landed? Looks like we just need to change the error message.

@nicolo-ribaudo nicolo-ribaudo added this to the v7.12.0 milestone Oct 14, 2020
@nicolo-ribaudo
Copy link
Member

(adding to the milestone so we don't forget to merge when the tests pass)

@nicolo-ribaudo
Copy link
Member

The failing test is also failing in main.

@nicolo-ribaudo nicolo-ribaudo changed the title fix(babel-parser) better error message for missing number exponent [parser] Better error message for missing number exponent Oct 14, 2020
@nicolo-ribaudo nicolo-ribaudo merged commit 59d97d9 into babel:main Oct 14, 2020
sosukesuzuki added a commit to sosukesuzuki/prettier that referenced this pull request Oct 16, 2020
sosukesuzuki added a commit to prettier/prettier that referenced this pull request Oct 20, 2020
* Install babel/parser 7.12

* Add tests for babel/babel#12161

* Add test for babel/babel#12076

* Add test for babel/babel#12085

* Add test for babel/babel#12108

* Add test for babel/babel#12120

* Add test for babel/babel#12054

* Add test for babel/babel#12061

* Add test babel/babel#12093

* Add test for babel/babel#12065

* Add test for babel/babel#12111

* Add test for babel/babel#12072

* Switch syntax-module-attributes to syntax-import-assertion

* Support "String import/export specifier"

* Remove tests for module-attributes

* Add changelog

* Update to 7.12.3

* Fix by linter

* Fix by spellchecker

* Add tests for module attributes to errors

* Add error test for module string name with import

* Remove TSTypeCastExpression

* Add tests for funny import-assertions

* Update snapshots|

* Add more tests
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jan 14, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: errors outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser PR: Polish 💅 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better error message for missing number exponent after "e"
6 participants