Conversation
|
It would be good to check that |
| | Pconst_string (s, _, Some delim) -> | ||
| wrap_k (str ("{" ^ delim ^ "|")) (str ("|" ^ delim ^ "}")) (str s) | ||
| | Pconst_string (s, None) -> ( | ||
| | Pconst_string (s, _, None) -> ( |
There was a problem hiding this comment.
One need to look for comments using the currently discarded locations
|
FTR, I suggested that the new location added to Pconst_string could replace the |
|
About comments attached to the new location: my understanding is that there is always a strict inclusion between the two locs: Consider a string literal as an expression, let's destructure it as The locs look like this: double quoted stringraw stringquoted extensionquoted extension with delimiterThere is no lexical way that I know of to put comments within |
|
I expect that by and large the comment placement behavior won't be affected due to the strict nesting. However, uses of |
|
I think this should be OK, we can refine that if necessary when we add tests for 4.11 features. So this seems ready to get merged in my eyes. What do you think @gpetiot ? |
|
(we'll add changelog entries for explicit 4.11 features) |
|
I don't think so. These new locs are not the location of the constants themselves, so no comments should get attached to them. The only place we can leverage the new locs is for re-lexing the payload. |
gpetiot
left a comment
There was a problem hiding this comment.
Looks good to me, thanks!
|
These new locs are not the location of the constants themselves
I'm curious: what are they the loc of then?
|
|
They are the loc for string contents (within delimiters), highlighted as |
This PR should add support for OCaml 4.11 to ocamlformat.
At the moment the tests fail during testing (
reformat_string.mlgets its comments removed), however it seems to be fixed by #1383.I'm not sure how critical the location fields are to ocamlformat so I'll let you decide whether the
locandLocation.noneare correctly placed here.Concerning the deprecation of
Longident.parseI can try to useParse.longidentinstead, however the semantics are different between the two functions, also I'm not sure how to get it without accessing tocompiler-libsdirectly asocaml-migrate-parsetreedoes not have the function.