-
Notifications
You must be signed in to change notification settings - Fork 99
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
Add -dune-optional-output mode for dune's internal use #482
base: main
Are you sure you want to change the base?
Conversation
0695d62
to
0609cea
Compare
(* Meant to be used after partitioning *) | ||
let rewrites_not_context_free t = | ||
match t with | ||
| { name; _ } when String.equal name builtin_context_free_name -> false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not quite sure I follow why checking this name is enough for deciding that this rewrite is not context free? Is it okay because we assume that people will not use that name externally (probably a fine assumption)? For example, if you change the driver_with_impl.ml
to be called
let () =
Driver.register_transformation ~impl:(fun str -> str) "<builtin:context-free>"
The pp file is no longer generated. Sorry this might just be that I am too new to the codebase!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ppxlib's driver will assemble several AST traversal passes. One of them is meant to apply all context-free rules, it is built by ppxlib itself and is named "builtin:context-free".
All other passes come from ppx-es registering str -> str
or sig -> sig
rewriting functions.
Indeed there are no guarantees a user won't use that name when registering a ppx of their own but it is very unlikely.
I think this all part of the code could be refactored and simplified significantly and that might help distinguish between this special pass and all others.
In the meantime we could try to forbid this name for outside users. The transformation name is only used for error reporting as far as I remember so it usually is the name of the ppx itself, it's unlikely that we would break anything by adding such a restriction.
I think it should be alright but if you feel this is too much of a risk, I'm happy to look into refactoring this part in a way that allows us not to check by name.
Fixes ocaml-ppx#461 This PR adds a new command line flag that tells the driver not to write to the output file if there is no rewriting to be done. It's not 100% accurate if there are non context free transformations registered as we do not compare the AST for this feature but simply keep track of generated code via a hook. If any non context free transformation is registered, we simply assume it will rewrite something and always output. Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
0609cea
to
524c67a
Compare
Fixes #461
This PR adds a new command line flag that tells the driver not to write to the output file if there is no rewriting to be done.
It's not 100% accurate if there are non context free transformations registered as we do not compare the AST for this feature but simply keep track of generated code via a hook.
If any non context free transformation is registered, we simply assume it will rewrite something and always output.