Relax syntax restriction on Pexp_new #6820
Currently, only a longident can be placed after the "new" keyword. This kind of restriction has been relaxed for several other piece of syntaxes (+ a check before typechecking). It would be useful to allow expressions there.
Initial motivation can be found here: ocsigen/js_of_ocaml#239 (comment)
(I just realized there is no "OCaml syntax/parser" category in mantis)
The text was updated successfully, but these errors were encountered:
Comment author: @alainfrisch
I would find this quite natural if the longident after "new" would indeed be resolved as expression path, but it's not the case. Why would we allow (syntactically) an expression after "new" and not, for instance, a type expression?
As for the initial motivation, what about:
Comment author: @Drup
I don't see how it could be a type expression. Classes are not types and you can't define them in a signature alone. When a class is defined, a class type of the same name is also defined (and in a different namespace!) but that's a completely different thing. If you define the class type alone, it doesn't give you a class.
Sure, this is what I will do, but I figured I could ask.