-
Notifications
You must be signed in to change notification settings - Fork 98
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
make Ast_builder.{e,p}list able to build lists such as a :: b :: c
#498
Conversation
6b0ef1d
to
4d0686c
Compare
In its current form this could potentially be a breaking change for some users. @patricoferris this could be a nice thing to try with a revdeps CI! Just to err on the safe side, I think it would be best to introduce new functions accepting the optional |
What kind of code do you imagine this would break? Given that 1) there aren't many ppxes 2) they break regularly due to upstream ast changes 3) the optional argument will be erased in the vast majority of cases, I don't really the reason to go out of our way to provide absolute backwards compatibilty ( |
I agree it is unlikely to break most of those, hence my wording above, but I want to avoid unnecessary breakage. As you pointed out, ppxlib does break when we update the internal AST so I'd rather avoid breaking changes outside of those releases as much as possible and it's unclear when the next one will happen. In particular, since we're going to merge support for OCaml trunk in the main branch, introducing breaking changes will impact anyone trying to test the dev version of the compiler. I understand it's annoying to have to care about the API stability in such cases but ppxlib is a rather central piece of the ecosystem and therefore one where we can't take this lightly. If you do not want to add separate functions, you can open a PR to opam-repository to trigger a build there to ensure this breaks no opam rev deps, otherwise I'll take care of it a bit later. If you're interested you can see how to |
I did a grep for Just looking at this information, which is a very natural thing to want to do, seems to be wholly unsupported by the tools: So I ended up doing this the low-tech way: opam search --depends-on ppxlib -s | while read name; do echo $name; (rm -rf /tmp/z; opam source --quiet $name --dir /tmp/z; (cd /tmp/z; rg '\belist')) < /dev/null; done |& tee /tmp/opam-grep Is there a good way to do this, or do people never look through opam for how something is used?
How is the opam file you point to created ? Is it manually copied from elsewhere in the repo and manually tweaked, or is it generated by dune-release with some specific arguments ? |
https://sherlocode.com/ can be a useful tool for this! The opam file I linked is just a copy of ppxlib's opam file with the |
Thanks. I created ocaml/opam-repository#26104, we'll see if I set it up correctly or not in a while apparently. |
It indeed breaks Could you add separate functions? In the long run we can devise a plan to drop the old versions smoothly. |
It indeed causes breakage, although I think this breakage is a compiler bug, as it doesn't make a whole lot of sense. let foo ?tail:_ ~loc l =
Ast_builder.Default.elist ~loc l
let gen_def_loc f x =
let loc : location = assert false in
f ~loc x
let _foo = gen_def_loc foo
9 | let _foo = gen_def_loc foo
^^^
Error: This expression has type
?tail:'a -> loc:location -> expression list -> expression
but an expression was expected of type loc:location -> 'b -> 'c
But if let foo ?tail:_ loc l =
Ast_builder.Default.elist ~loc l
let gen_def_loc f x =
let loc : location = assert false in
f loc x
let _foo = gen_def_loc foo
(* compiles fines *) In any case, I'll add other functions because even if the compiler gets fixed, it's going months in the best case scenario. |
It's not clear what name to give a function that's exactly the same as another one. I used |
It's not a compiler bug but a limitation of type inference when it comes to labeled arguments. It's all explained in detail here: https://ocaml.org/manual/5.2/lablexamples.html#s:label-inference. I agree naming isn't easy here. We've been using |
I guess we can just call the function |
Signed-off-by: Valentin Gatien-Baron <[email protected]>
I guess the one advantage of using a separate module here is that we could imagine in the future re-exposing the whole I don't have a strong opinion on this so I'll leave to you to decide what you prefer here. |
I was imagining bundling the replacement of But in any case, since I'm not going to be the one doing any of this, I think it'd be simpler if you told me what you prefer. |
Let's merge this as it is, we can always change it when we release. |
Thanks ! |
We could just make separate constructors for improper lists, and have |
- Fix a bug where `Code_path.main_module_name` would not properly remove extensions from the filename and therefore return an invalid module name. (ocaml-ppx/ppxlib#512, @NathanReb) - Add `-unused-type-warnings` flag to the driver to allow users to disable only the generation of warning 34 silencing structure items when using `[@@deriving ...]` on type declarations. (ocaml-ppx/ppxlib#511, @mbarbin, @NathanReb) - Make `-unused-code-warnings` flag to the driver also controls the generation of warning 34 silencing structure items when using `[@@deriving ...]` on type declarations. (ocaml-ppx/ppxlib#510, @mbarbin, @NathanReb) - Driver: Add `-unused-code-warnings=force` command-line flag argument. (ocaml-ppx/ppxlib#490, @mbarbin) - new functions `Ast_builder.{e,p}list_tail` that take an extra tail expression/pattern argument parameter compared to `Ast_builder.{e,p}list`, so they can build ASTs like `a :: b :: c` instead of only `[ a; b ]`. (ocaml-ppx/ppxlib#498, ocaml-ppx/ppxlib#502, @v-gb, @NathanReb) - Fix `Longident.parse` so it also handles indexing operators such as `.!()`, `.%(;..)<-`, or `Vec.(.%())` (ocaml-ppx/ppxlib#494, @Octachron) - Add a `special_function'` variant which directly takes a `Longident.t` argument to avoid the issue that `Longident.t` cover distinct syntaxic classes which cannot be easily parsed by a common parser (ocaml-ppx/ppxlib#496, @Octachron). - Keep location ranges consistent when migrating `Pexp_function` nodes from 5.2+ to older versions (ocaml-ppx/ppxlib#504, @jchavarri) - Fix `-locations-check` behaviour so it is no longer required to pass `-check` as well to enable location checks. (ocaml-ppx/ppxlib#506, @NathanReb) Signed-off-by: Nathan Rebours <[email protected]>
- Fix a bug where `Code_path.main_module_name` would not properly remove extensions from the filename and therefore return an invalid module name. (ocaml-ppx/ppxlib#512, @NathanReb) - Add `-unused-type-warnings` flag to the driver to allow users to disable only the generation of warning 34 silencing structure items when using `[@@deriving ...]` on type declarations. (ocaml-ppx/ppxlib#511, @mbarbin, @NathanReb) - Make `-unused-code-warnings` flag to the driver also controls the generation of warning 34 silencing structure items when using `[@@deriving ...]` on type declarations. (ocaml-ppx/ppxlib#510, @mbarbin, @NathanReb) - Driver: Add `-unused-code-warnings=force` command-line flag argument. (ocaml-ppx/ppxlib#490, @mbarbin) - new functions `Ast_builder.{e,p}list_tail` that take an extra tail expression/pattern argument parameter compared to `Ast_builder.{e,p}list`, so they can build ASTs like `a :: b :: c` instead of only `[ a; b ]`. (ocaml-ppx/ppxlib#498, ocaml-ppx/ppxlib#502, @v-gb, @NathanReb) - Fix `Longident.parse` so it also handles indexing operators such as `.!()`, `.%(;..)<-`, or `Vec.(.%())` (ocaml-ppx/ppxlib#494, @Octachron) - Add a `special_function'` variant which directly takes a `Longident.t` argument to avoid the issue that `Longident.t` cover distinct syntaxic classes which cannot be easily parsed by a common parser (ocaml-ppx/ppxlib#496, @Octachron). - Keep location ranges consistent when migrating `Pexp_function` nodes from 5.2+ to older versions (ocaml-ppx/ppxlib#504, @jchavarri) - Fix `-locations-check` behaviour so it is no longer required to pass `-check` as well to enable location checks. (ocaml-ppx/ppxlib#506, @NathanReb) Signed-off-by: Nathan Rebours <[email protected]>
No description provided.