Longident.parse is deprecated
Fedora Rawhide currently has a prerelease of OCaml 4.11. Building ppxlib now fails like so:
File "src/gen/import.ml", line 14, characters 21-36:
14 | let lident x = mk (Longident.parse x)
^^^^^^^^^^^^^^^
Error (alert deprecated): Longident.parse
this function may misparse its input,
use "Parse.longident" or "Longident.unflatten"
What is the right thing to do? Should I disable the alert and leave the code as is? Would it be correct to replace (Longident.parse x) with (Parse.longident (Lexing.from_string x))?
We should disable the alert in ppxlib. In the upcoming ppx project, we should stop using this function and also change the signature of this helper. The current method is too stringly typed.
I've just seen this. With the change to Astlib, on new compilers I have indeed replaced (Longident.parse x) with (Parse.longident (Lexing.from_string x)) now (see here). @jeremiedimino , what did you mean with "also change the signature of this helper"? Would you take a lexbuf as input rather than a string?
IIRC, there is a function lident : string -> Longident.t that alloows one to write lident "Foo.bar" to produce a Lident (Ldot (Lident "Foo", "Bar")). That seems too magical. When we want to write a constant identifier in the code we should write the structured version: Lident (Ldot (Lident "Foo", "Bar")), or alternatively use a function that makes it clear it's doing parsing, for instance by seeing "parse" in the function name.
Put another way, I would expect a function lident : string -> Longident.t to be just let lident x = Lident x. I wouldn't expect it to create a lexing buffer and do some lexing and parsing.
Ok, I see. In Astlib that should be fine then since I've called that function Longident.parse. I'll leave this open though, since the confusion you're describing is still in Ppxlib.Ast_builder.