Skip to content

Better error message for missing number exponent after "e" #12071

@nicolo-ribaudo

Description

@nicolo-ribaudo

Feature Request

Is your feature request related to a problem?
Consider this (invalid) code:

12.3e

It throws this error:

Invalid number (1:0)

Describe the solution you'd like

It should throw something like

Missing exponent after 'e' in floating-point number

If you are interested in fixing this bug, you should introduce a new error message and use it in the "tokenizer": the part of the parser which takes the input source code as a string and generates a set of corresponding tokens (1.2, foo, +, "baz", var, ...).

⚠️ SPOLIER (it's here, but first try finding it yourself!)

If it is the first time that you contribute to Babel, follow these steps: (you need to have make and yarn available on your machine)

  1. Write a comment there to let other possible contributors know that you are working on this bug.
  2. Fork the repo
  3. Run git clone https://github.com/<YOUR_USERNAME>/babel.git && cd babel
  4. Run yarn && make bootstrap
  5. Wait ⏳
  6. Run make watch (or make build whenever you change a file)
  7. Add a test We probably already have tests for this with the "bad" error message
  8. Update the code!
  9. yarn jest babel-parser to run the tests
    • If some test outputs don't match but the new results are correct, you can delete the bad output.json files and run the tests again
    • If you prefer, you can run OVERWRITE=true yarn jest babel-parser and they will be automatically updated.
  10. If it is working, run make test to run all the tests
  11. Run git push and open a PR!

If you need any help, feel free to reply here or write me on slack!

Metadata

Metadata

Assignees

Labels

claimedgood first issueoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions