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
does not print "let open" correctly in "if" #7196
Comments
Comment author: craff I wrote major, because this can break bootstraping of -pp or -ppx extensions Actually this broke decap bootstrap at some point and forced me not to use the "let open" syntax inside conditions Moreover, this should be an easy fix ... |
Comment author: @gasche Indeed, this was very simple to fix: Despite a few rewrites, the pretty-printing machinery is still baroque and I wouldn't trust it. It would be nice to overhaul it to exactly match the precedence levels and nonterminals used in the parser, to get verifiably correct minimal parentheses insertion. I'd rather get the parser converted to Menhir first to work from a nicer grammar. |
Comment author: craff I use extensively the pretty printing to bootstrap decap and this is the first time I have a problem ... What would be a real gain is to change the grammar itself, the priority of This is a nightmare if you do not use the yacc way of giving precedence, The nice things, is that changing the grammar at this place actually breaks little code (I tested), and can be easily detected by parsing both with the old and the new parser. I would suggest a few deep revision of the syntax (in places that hurt students):
If this change are not mandatory, a smooth transition is possible |
Comment author: craff And thanks for the fix !!! |
Original bug ID: 7196
Reporter: craff
Assigned to: @gasche
Status: closed (set by @xavierleroy on 2017-09-24T15:32:16Z)
Resolution: fixed
Priority: normal
Severity: major
Platform: linux
OS: Debian
OS Version: stable
Version: 4.02.3
Fixed in version: 4.03.0+dev / +beta1
Category: ~DO NOT USE (was: OCaml general)
Monitored by: runhang @hcarty
Bug description
Consider the following file
let _ =
if true then (
let open List in
();
());
()
The pretty printing of ast is wrong:
$ ocamlc -dsource bug.ml
let _ = if true then let open List in ((); ()); ()
it should be
let _ = if true then (let open List in ((); ())); ()
Otherwise, the last unit is parser inside the then branch.
Steps to reproduce
Given above
Additional information
4.03.0 is affected too, I did not check 4.01.0
The text was updated successfully, but these errors were encountered: