Skip to content
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

pretty-printer loses parens in "if (1 == fail) { }" #929

Closed
jruderman opened this Issue Sep 16, 2011 · 3 comments

Comments

Projects
None yet
3 participants
@jruderman
Copy link
Contributor

jruderman commented Sep 16, 2011

fn f() { if (1 == fail) { } else { } }

and

fn f() { if 1 == (fail) { } else { } }

lose their parens, becoming something that fails to parse:

fn f() { if 1 == fail { } else { } }

This could be solved by parenthesizing the whole discriminant, parenthesizing just the "fail", or getting rid of the syntactic ambiguity. I see a way to do the first option, by making pprust::print_maybe_parens_discrim recurse right. I could write that patch, along with tests, if you think it's the right thing to do.

@brson

This comment has been minimized.

Copy link
Contributor

brson commented Feb 6, 2012

Yes, I agree with your solution. print_maybe_parens_discrim should be looking at the rightmost expression.

brson added a commit that referenced this issue Feb 6, 2012

@ghost ghost assigned catamorphism Mar 15, 2012

@catamorphism

This comment has been minimized.

Copy link
Contributor

catamorphism commented Jul 26, 2012

Reproduced as of 7/26/2012.

@catamorphism

This comment has been minimized.

Copy link
Contributor

catamorphism commented Nov 16, 2012

Fixed now that we have paren nodes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.