-
Notifications
You must be signed in to change notification settings - Fork 596
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
Fix handling of underscores in numeric literals semantic #3314
Conversation
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.
Reviewable status: 0 of 3 files reviewed, all discussions resolved (waiting on @orizi)
crates/cairo-lang-syntax/src/node/ast_ext.rs
line 53 at r1 (raw file):
// Catch an edge case, where literal seems to have a suffix that is valid numeric part // according to the radix. Interpret this as an untyped numer. // Example: 0x1_f32 is interpreted as 0x1F32 without suffix.
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=fd921710d30da70c6fda84e016b2cd0f this matches Rust's behaviour
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.
Reviewed all commit messages.
Reviewable status: 0 of 3 files reviewed, 1 unresolved discussion (waiting on @mkaput)
a discussion (no related file):
note that this PR does not fix anything - as _ in the middle of a number are not supported in cairo.
this PR adds them - which we are yet to be sure we should.
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.
Reviewable status: 0 of 3 files reviewed, 1 unresolved discussion (waiting on @orizi)
a discussion (no related file):
Previously, orizi wrote…
note that this PR does not fix anything - as _ in the middle of a number are not supported in cairo.
this PR adds them - which we are yet to be sure we should.
Hmm, the trick is parser already supports _
(otherwise tests I added would fail) and people were trying to use these. The examples in tests are based on a bug report I got from my user who claimed they saw this being used in the wild (all of this was happening on DMs, so I cannot link references).
So I understand this was just an unexpected feature?
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.
Reviewed 3 of 3 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @mkaput)
crates/cairo-lang-syntax/src/node/ast_ext.rs
line 79 at r1 (raw file):
} Some(ty.into()) }
delete this as well.
Code quote:
/// Get suffix from this literal if it has one.
pub fn suffix(&self, db: &dyn SyntaxGroup) -> Option<SmolStr> {
let text = self.text(db);
let (_literal, ty) = text.rsplit_once('_')?;
if ty.is_empty() {
return None;
}
Some(ty.into())
}
See added test cases for failing cases examples. commit-id:8bd1ae1d
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.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @orizi)
crates/cairo-lang-syntax/src/node/ast_ext.rs
line 79 at r1 (raw file):
Previously, orizi wrote…
delete this as well.
Done.
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.
Reviewable status: 0 of 3 files reviewed, all discussions resolved (waiting on @mkaput)
See added test cases for failing cases examples.
This change is