Fix unary minus rendering into -- line comments - #2532
Open
LucaCappelletti94 wants to merge 1 commit into
Open
LucaCappelletti94 wants to merge 1 commit into
LucaCappelletti94 wants to merge 1 commit into
Conversation
LucaCappelletti94
marked this pull request as ready for review
September 19, 2026 20:10
6 tasks
alamb
approved these changes
Sep 21, 2026
| | UnaryOperator::QuestionDash | ||
| | UnaryOperator::QuestionPipe | ||
| ) { | ||
| ) || (op == &UnaryOperator::Minus && starts_with_operator_char(expr)) |
Contributor
There was a problem hiding this comment.
Same comment as #2533 (comment) -- I think if you restructured this code to match it would be easier to undertstand the behavior and coverage
LucaCappelletti94
force-pushed
the
unary-minus-comment-guard
branch
from
September 21, 2026 13:19
25e01ac to
206a5f4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fuzz round-trip found
SELECT - -1rendering asSELECT --1, which re-parses as a line comment in every dialect except MySQL, andSELECT - @2rendering asSELECT -@2in PostgreSQL, where-@retokenizes as one custom operator and parsing fails. Same fusion hits- ~1(-~1),- !!2(-!!2),- ||/2(-||/2) and- #x(-# x).Expr::UnaryOpdisplay concatenates operator and operand in its final arm. The fix emits a space when the operator is-and the operand renders with a leading operator character. The first character is probed through a discarding write sink, so canonical output like-1or-xis unchanged and nothing allocates. Backtick-quoted operands and-?placeholders keep their current rendering because those dialects have no fusion rule and the characters stay out of the set.There are some other variants of this error, but they are sufficiently distinct that I believe it is best to adress them in distinct PRs.