Skip to content

Suggest keyword hints for logical operators - #164

Merged
simontreanor merged 2 commits into
simontreanor:mainfrom
PandaHUN777:fix/logical-operator-hints-136
Oct 17, 2026
Merged

simontreanor merged 2 commits into
simontreanor:mainfrom
PandaHUN777:fix/logical-operator-hints-136

Conversation

@PandaHUN777

Copy link
Copy Markdown
Contributor

Closes #136

Suggest Pyfun's and and or keywords when users write && or ||.

Validation:

  • cargo fmt --check
  • cargo clippy --all-targets
  • cargo test

@simontreanor simontreanor left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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 simontreanor left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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.

@simontreanor
simontreanor merged commit 6dc5c81 into simontreanor:main Oct 17, 2026
22 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.

Say and/or when someone writes && or ||

2 participants