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

Fix untypeast/pprintast bug (backport upstream 13845) #3663

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ccasin
Copy link
Contributor

@ccasin ccasin commented Mar 5, 2025

This tiny PR backports ocaml/ocaml#13845 to fix a bug in untypeast/pprintast.

It has already been reviewed upstream so low scrutiny is appropriate. The only question on our end is whether we need to do anything special about modes, and I think the answer is no because both let x @ local = ... and let (x @ local) = ... are valid syntax.

Request review from @tdelvecchio-jsc

@ccasin ccasin requested a review from tdelvecchio-jsc March 5, 2025 18:39
Copy link
Contributor

@tdelvecchio-jsc tdelvecchio-jsc left a comment

Choose a reason for hiding this comment

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

It seems worthwhile to test modes here? In particular, a weird thing is

let (f @ mode) = fun x -> x

is valid, but

let (f @ mode) : 'a. 'a -> 'a = fun x -> x

is not.

@ccasin ccasin force-pushed the untypeast-pprint-bug branch from 55fff3e to f227150 Compare March 5, 2025 19:49
@ccasin
Copy link
Contributor Author

ccasin commented Mar 5, 2025

It seems worthwhile to test modes here? In particular, a weird thing is

let (f @ mode) = fun x -> x

is valid, but

let (f @ mode) : 'a. 'a -> 'a = fun x -> x

is not.

@tdelvecchio-jsc Good question. It turns out that the untypeast/pprintast combo is just totally broken on value bindings involving modes. This PR neither fixes nor causes this.

I don't have time to debug it today - what I've done is to add a test demonstrating it's broken in the first commit. The second commit doesn't fix it, but at least we know it's not the cause. I propose merging this as is and fixing this another day.

Copy link
Contributor

@tdelvecchio-jsc tdelvecchio-jsc left a comment

Choose a reason for hiding this comment

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

See comment, but otherwise fine with me.

pat, Some constr, modes
| _ -> pat, None, []
in
Vb.mk ~loc ~attrs ?value_constraint ~modes pat (sub.expr sub vb.vb_expr)
Copy link
Contributor

Choose a reason for hiding this comment

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

This currently drops vb.pvb_modes. If you are fine with that since modes are broken anyways then that's fine, but wanted to point it out.

@ccasin ccasin added typing lexer/parser Changes to the lexer and parser labels Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lexer/parser Changes to the lexer and parser typing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants