Skip to content

pretty-printer does not parenthesize ret expr in callee position #891

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

Closed
jruderman opened this issue Sep 10, 2011 · 3 comments
Closed

pretty-printer does not parenthesize ret expr in callee position #891

jruderman opened this issue Sep 10, 2011 · 3 comments
Labels
A-pretty Area: Pretty printing (including `-Z unpretty`)

Comments

@jruderman
Copy link
Contributor

(ret g)(41)

becomes

ret g(41)

Here's an invalid program that gets transformed into a program that prints 42.

fn f(g: fn(int) -> int) -> int { (ret g)(41) }
fn succ(x: int) -> int { x + 1 }
fn main() { log_err f(succ); }
@brson
Copy link
Contributor

brson commented Sep 11, 2011

I don't know if we should expend compiler complexity on pretty-printing bogus code. Besides making life easier for fuzzers, is there any value in making this work? Is it possible to express valid code that has this same problem?

@jruderman
Copy link
Contributor Author

Making life easier for fuzzers can be worthwhile ;)

@marijnh
Copy link
Contributor

marijnh commented Sep 12, 2011

I think consistency is worthwhile. Bad corner-cases, even if they are for weird code, are a sign of an ambiguous/confusing grammar, which is not a nice property of a language.

coastalwhite pushed a commit to coastalwhite/rust that referenced this issue Aug 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-pretty Area: Pretty printing (including `-Z unpretty`)
Projects
None yet
Development

No branches or pull requests

3 participants