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

feat/support underscore in numberic #701

Merged

Conversation

vuvoth
Copy link
Contributor

@vuvoth vuvoth commented May 6, 2022

Proposed Changes

Support underscore for readable in numberic type.
Close #149

Implementation

  • Add regex rule to parser/lexer/token.rs

Please review my PR! Thanks!

To-Do

  • OPTIONAL: Update Spec if applicable

  • Add entry to the release notes (may forgo for trivial changes)

  • Clean up commit history

@codecov-commenter
Copy link

codecov-commenter commented May 6, 2022

Codecov Report

Merging #701 (002f667) into master (d580097) will decrease coverage by 0.03%.
The diff coverage is 68.75%.

❗ Current head 002f667 differs from pull request most recent head c70184b. Consider uploading reports for the commit c70184b to get more accurate results

@@            Coverage Diff             @@
##           master     #701      +/-   ##
==========================================
- Coverage   82.03%   81.99%   -0.04%     
==========================================
  Files         125      125              
  Lines       10891    10937      +46     
==========================================
+ Hits         8934     8968      +34     
- Misses       1957     1969      +12     
Impacted Files Coverage Δ
crates/parser/src/ast.rs 87.53% <0.00%> (-1.01%) ⬇️
crates/parser/src/lexer/token.rs 17.97% <ø> (ø)
crates/parser/src/grammar/functions.rs 89.27% <72.50%> (-1.25%) ⬇️
crates/lowering/src/mappers/functions.rs 99.42% <100.00%> (+<0.01%) ⬆️
crates/lowering/src/mappers/module.rs 85.54% <100.00%> (+0.17%) ⬆️
crates/yulgen/src/runtime/abi_dispatcher.rs 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d580097...c70184b. Read the comment docs.

Copy link
Collaborator

@cburgdorf cburgdorf left a comment

Choose a reason for hiding this comment

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

Great!

Could you also add another test case here to prove that something like 100_000_ or _1_0 is still rejected.

test_parse_err! { expr_dotted_number, expressions::parse_expr, "3.14" }

Lastly, can you add a file newsfragments/149.feature.md with the contents being something like

Support for underscores in numbers to improve readability e.g. `100_000`

This is to ensure the feature will be included in the upcoming release notes.

@vuvoth
Copy link
Contributor Author

vuvoth commented May 6, 2022

Could you also add another test case here to prove that something like 100_000_ or _1_0 is still rejected.

I have problem is when I write "fail tests" case error but snap file body is empty. How I can handle it?

Lastly, can you add a file newsfragments/149.feature.md with the contents being something like

I don't know format of the newfragments files. Have any source for me to reference ?

@vuvoth vuvoth requested a review from cburgdorf May 6, 2022 13:49
@sbillig
Copy link
Collaborator

sbillig commented May 7, 2022

I have problem is when I write "fail tests" case error but snap file body is empty. How I can handle it?

I guess you probably figured this out, but the snapshot testing stuff uses insta. You can just add a new test and run it. The test will initially fail, because the new snapshot won't match the "current" (non-existent) snapshot. To accept the snapshot, it's easiest to use cargo insta review (which requires a cargo install cargo-insta first).

I don't know format of the newfragments files. Have any source for me to reference ?

Usually there are some examples in there, but they're removed on every release and added to the changelog. What you have is good, just drop the leading # and add a trailing newline.

@vuvoth vuvoth changed the title feat/support_underscore_numberic feat/support underscore in numberic May 9, 2022
@cburgdorf cburgdorf merged commit f85c6e3 into ethereum:master May 10, 2022
@cburgdorf
Copy link
Collaborator

Thank you very much for your work @vuvoth
Merged! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support underscores in numeric literals
4 participants