-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add bitwise_for_parity_check #83
base: main
Are you sure you want to change the base?
Add bitwise_for_parity_check #83
Conversation
4069c2a
to
fd0e93b
Compare
2892a93
to
e76d7fd
Compare
|
||
//! > cairo_code | ||
fn main() { | ||
let a = 200 & 1; |
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.
let a = 200 & 1; | |
let a = 200_u32 & 1; |
pub fn fix_bitwise_for_parity_check(&self, db: &dyn SyntaxGroup, node: ExprBinary) -> String { | ||
let lhs = node.lhs(db).as_syntax_node().get_text(db); | ||
|
||
format!("DivRem::div_rem({}, 2)", lhs.trim()) |
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.
format!("DivRem::div_rem({}, 2)", lhs.trim()) | |
format!("{} % 2", lhs.trim()) |
pub const BITWISE_FOR_PARITY: &str = | ||
"You seem to be trying to use `&` for parity check. Consider using `DivRem::div_rem()` instead."; | ||
|
||
pub fn check_bitwise_for_parity(db: &dyn SyntaxGroup, node: &ExprBinary, diagnostics: &mut Vec<PluginDiagnostic>) { |
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.
You should check that this type indeed implements DivRem
so i don't think you should be using SyntaxGroup
but use SemanticGroup
closes #65