-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: underscores and literals validation (#165)
* feat: remove trailing underscores * literals * fix * fix: remove print statement * fix: suggestions * demo expr recursed * Update crates/sema/src/ast_passes.rs --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
- Loading branch information
1 parent
6d905ab
commit 2876a11
Showing
3 changed files
with
110 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
contract LT { | ||
uint256 a = 1000_; //~ERROR: invalid use of underscores in number literal | ||
uint256 b = 100__0; //~ERROR: invalid use of underscores in number literal | ||
uint256 c = 1_.4e10; //~ERROR: invalid use of underscores in number literal | ||
uint256 d = 3.4_e10; //~ERROR: invalid use of underscores in number literal | ||
uint256 e = 3.4e_10; //~ERROR: invalid use of underscores in number literal | ||
|
||
// exception | ||
uint256 f = 3._4e10; // Does not show up | ||
|
||
uint256 g = 1_.4e10 + 3.4e_10; //~ERROR: invalid use of underscores in number literal | ||
//~^ERROR: invalid use of underscores in number literal | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
error: invalid use of underscores in number literal | ||
--> ROOT/tests/ui/resolve/literals_underscores.sol:LL:CC | ||
| | ||
LL | uint256 a = 1000_; | ||
| ^^^^^ | ||
| | ||
= help: remove trailing underscores | ||
|
||
error: invalid use of underscores in number literal | ||
--> ROOT/tests/ui/resolve/literals_underscores.sol:LL:CC | ||
| | ||
LL | uint256 b = 100__0; | ||
| ^^^^^^ | ||
| | ||
= help: only 1 consecutive underscore `_` is allowed between digits | ||
|
||
error: invalid use of underscores in number literal | ||
--> ROOT/tests/ui/resolve/literals_underscores.sol:LL:CC | ||
| | ||
LL | uint256 c = 1_.4e10; | ||
| ^^^^^^^ | ||
| | ||
= help: remove underscores in front of the fraction part | ||
|
||
error: invalid use of underscores in number literal | ||
--> ROOT/tests/ui/resolve/literals_underscores.sol:LL:CC | ||
| | ||
LL | uint256 d = 3.4_e10; | ||
| ^^^^^^^ | ||
| | ||
= help: remove underscores at the end of the mantissa | ||
|
||
error: invalid use of underscores in number literal | ||
--> ROOT/tests/ui/resolve/literals_underscores.sol:LL:CC | ||
| | ||
LL | uint256 e = 3.4e_10; | ||
| ^^^^^^^ | ||
| | ||
= help: remove underscores in front of the exponent | ||
|
||
error: invalid use of underscores in number literal | ||
--> ROOT/tests/ui/resolve/literals_underscores.sol:LL:CC | ||
| | ||
LL | uint256 g = 1_.4e10 + 3.4e_10; | ||
| ^^^^^^^ | ||
| | ||
= help: remove underscores in front of the fraction part | ||
|
||
error: invalid use of underscores in number literal | ||
--> ROOT/tests/ui/resolve/literals_underscores.sol:LL:CC | ||
| | ||
LL | uint256 g = 1_.4e10 + 3.4e_10; | ||
| ^^^^^^^ | ||
| | ||
= help: remove underscores in front of the exponent | ||
|
||
error: aborting due to 7 previous errors | ||
|