Repository navigation
Suggest keyword hints for logical operators - #164
Conversation
simontreanor
left a comment
There was a problem hiding this comment.
Thanks! The && half is exactly right. There's one small thing in the || half:
self.error(...) always appends , found <token>, so the message comes out as
error: use `or` instead of `||`, found `|`
Could you build the ParseError directly instead, the way the return hint in #148 does?
Tok::Bar if matches!(self.peek2(), Tok::Bar) => {
return Err(ParseError {
message: "use `or` instead of `||`".to_string(),
span: self.span(),
});
}A heads-up as well: #148 adds an arm at the same spot in parse_atom and a test at the end of tests/roundtrip.rs. I'm merging that one first, so this branch will need a rebase onto main. The conflict is just "keep both".
Brings the branch up to date with main, keeping both this PR's `||` arm and the `return` arm simontreanor#148 added beside it. The `||` hint now builds its ParseError directly, since `self.error` appended ", found `|`" to the message, and the test pins the exact text.
simontreanor
left a comment
There was a problem hiding this comment.
Thanks again for this! I've pushed the small change from my review so it can make the 0.10.0 release: the || arm now builds its ParseError directly, and the test pins the exact message. I also merged main in, keeping your arm beside the return hint from #148. Merging once CI is green.
Closes #136
Suggest Pyfun's
andandorkeywords when users write&&or||.Validation:
cargo fmt --checkcargo clippy --all-targetscargo test