-
Notifications
You must be signed in to change notification settings - Fork 30
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: underscores and literals validation #165
feat: underscores and literals validation #165
Conversation
crates/sema/src/ast_passes.rs
Outdated
// Intentionally override unused default implementations to reduce bloat. | ||
fn visit_expr(&mut self, _expr: &'ast ast::Expr<'ast>) -> ControlFlow<Self::BreakValue> { | ||
let ast::Expr { kind, .. } = _expr; | ||
if let ast::ExprKind::Lit(lit, _) = kind { | ||
self.check_underscores_in_number_literals(lit); | ||
} | ||
ControlFlow::Continue(()) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now this also has to recurse into other expressions and types, so remove the comment, the visit_ty
implementation, and add walk_expr
at the end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
uint256 g = 1_.4e10 + 3.4e_10; //~ERROR: invalid use of underscores in number literal | ||
//~^ERROR: invalid use of underscores in number literal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added this to prove that expression recursion works for this error message
https://github.com/ethereum/solidity/blob/df01dcc7b759f53ba45811979d3286562eab7846/libsolidity/analysis/SyntaxChecker.cpp#L288C1-L322C14