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

Allow hex/octal/binary radix numeric literals #410

Merged
merged 4 commits into from
May 20, 2021

Conversation

Y-Nak
Copy link
Member

@Y-Nak Y-Nak commented May 20, 2021

What was wrong?

closes #333

How was it fixed?

  1. Added common::numeric::Literal to abstract string represented numeric literals.
  2. Consistently use BigInt for semantic analysis, this approach is the same as rustc does (it holds u128 for numeric integers).
  3. Removed lexical_core because it doesn't provide from_str_radix like methods. And also, I think we don't need to check the details of IntErrorKind in almost all cases. This is because, looking at the definition of IntErrorKind in detail, IntErrorKind::Empty is the only error kind that we have to consider it an internal compiler error.

To-Do

We may need to reconsider the usage of BigInt, I think it would be better to use U256 because:

  1. it provides more reliability than multiple-precision arithmetic.
  2. it improves performance a little bit.

  • 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 20, 2021

Codecov Report

Merging #410 (8513f75) into master (3d1a9da) will increase coverage by 0.03%.
The diff coverage is 94.91%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #410      +/-   ##
==========================================
+ Coverage   86.20%   86.23%   +0.03%     
==========================================
  Files          67       68       +1     
  Lines        4110     4135      +25     
==========================================
+ Hits         3543     3566      +23     
- Misses        567      569       +2     
Impacted Files Coverage Δ
compiler/src/yul/mappers/expressions.rs 88.67% <ø> (ø)
parser/src/lexer/token.rs 21.97% <25.00%> (-0.75%) ⬇️
analyzer/src/namespace/types.rs 84.83% <100.00%> (-0.23%) ⬇️
analyzer/src/traversal/expressions.rs 92.82% <100.00%> (+0.11%) ⬆️
common/src/numeric.rs 100.00% <100.00%> (ø)
parser/src/grammar/expressions.rs 88.33% <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 3d1a9da...8513f75. Read the comment docs.

Copy link
Collaborator

@sbillig sbillig left a comment

Choose a reason for hiding this comment

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

Looks great!

analyzer/src/traversal/expressions.rs Outdated Show resolved Hide resolved
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.

Allow hexadecimal/octal/binary numeric literals
3 participants