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: underscores and literals validation #165

Merged
merged 8 commits into from
Dec 12, 2024

Conversation

@TilakMaddy TilakMaddy marked this pull request as ready for review December 11, 2024 11:38
Comment on lines 316 to 324
// 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(())
}

Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@TilakMaddy TilakMaddy marked this pull request as draft December 12, 2024 07:23
@TilakMaddy TilakMaddy marked this pull request as ready for review December 12, 2024 07:28
Comment on lines +11 to +12
uint256 g = 1_.4e10 + 3.4e_10; //~ERROR: invalid use of underscores in number literal
//~^ERROR: invalid use of underscores in number literal
Copy link
Contributor Author

@TilakMaddy TilakMaddy Dec 12, 2024

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

crates/sema/src/ast_passes.rs Outdated Show resolved Hide resolved
@DaniPopes DaniPopes enabled auto-merge (squash) December 12, 2024 16:56
@DaniPopes DaniPopes merged commit 2876a11 into paradigmxyz:main Dec 12, 2024
12 checks passed
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.

2 participants