8000 Fix cli cookies handling by pitag-ha · Pull Request #209 · ocaml-ppx/ppxlib · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix cli cookies handling #209

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

Merged
merged 2 commits into from
Jan 18, 2021
Merged

Fix cli cookies handling #209

merged 2 commits into from
Jan 18, 2021

Conversation

pitag-ha
Copy link
Member
@pitag-ha pitag-ha commented Jan 15, 2021

Before, cookies handed in through the cli were added to the Ast_mapper cookies reference right away when reading the cli arguments. But in the case of a binary AST input, that reference gets reset to only contain the cookies from the ppx context when parsing that context (here the reference gets reset instead of appending to it). Therefore, cli cookies were ignored for binary AST inputs.

This commit fixes that by adding the cli cookies to the Ast_mapper cookies reference after parsing the ppx context.

Probably related to janestreet/ppx_expect#26 and to the last comment in janestreet/ppx_inline_test#1

@pitag-ha pitag-ha requested a review from xclerc as a code owner January 15, 2021 18:43
@ghost ghost requested review from a user and NathanReb and removed request for xclerc January 18, 2021 10:03
@pitag-ha pitag-ha requested a review from ceastlund as a code owner January 18, 2021 10:05
Before, cookies handed in through the cli were added to the `Ast_mapper`
cookies reference right away when reading the cli arguments. But in the
case of a binary AST input, that reference gets reset to only contain
the cookies from the ppx context when parsing that context. Therefore,
cli cookies were ignored for binary AST inputs.

This commit fixes that by adding the cli cookies to the `Ast_mapper`
cookies reference after parsing the ppx context.

Signed-off-by: Sonja Heinze <sonjaleaheinze@gmail.com>
Since the `-cookie` argument can also be used together with the `-as-ppx`
argument and when using `run_as_ppx_rewriter` as entry point, it should
form part of shared_args instead of standalone_args. Otherwise, the
documentation doesn't reflect the behavior.

Signed-off-by: Sonja Heinze <sonjaleaheinze@gmail.com>
Copy link
@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

DIdn't realise that drop_ppx_context_str was resetting all the cookies, that's good to know.

@pitag-ha pitag-ha merged commit 88a4c04 into ocaml-ppx:master Jan 18, 2021
NathanReb added a commit to NathanReb/opam-repository that referenced this pull request Jan 20, 2021
CHANGES:

- Driver (important for bucklescript): handling binary AST's, accept any
  supported version as input; preserve that version (ocaml-ppx/ppxlib#205, @pitag-ha)

- `-as-ppx`: take into account the `-loc-filename` argument (ocaml-ppx/ppxlib#197, @pitag-ha)

- Add input name to expansion context (ocaml-ppx/ppxlib#202, @pitag-ha)

- Add Driver.V2: give access to expansion context in whole file transformation
  callbacks of `register_transformation` (ocaml-ppx/ppxlib#202, @pitag-ha)

- Driver: take `-cookie` argument into account, also when the input is a
  binary AST (@pitag-ha, ocaml-ppx/ppxlib#209)

- `run_as_ppx_rewriter`: take into account the arguments
  `-loc-filename`, `apply` and `dont-apply` (ocaml-ppx/ppxlib#205, @pitag-ha)

- Location.Error: add functions `raise` and `update_loc`
  (ocaml-ppx/ppxlib#205, @pitag-ha)
NathanReb added a commit to NathanReb/opam-repository that referenced this pull request Jan 22, 2021
CHANGES:

- Fix ppxlib.traverse declaration and make it a deriver and not a rewriter
  (ocaml-ppx/ppxlib#213, @NathanReb)
- Driver (important for bucklescript): handling binary AST's, accept any
  supported version as input; preserve that version (ocaml-ppx/ppxlib#205, @pitag-ha)

- `-as-ppx`: take into account the `-loc-filename` argument (ocaml-ppx/ppxlib#197, @pitag-ha)

- Add input name to expansion context (ocaml-ppx/ppxlib#202, @pitag-ha)

- Add Driver.V2: give access to expansion context in whole file transformation
  callbacks of `register_transformation` (ocaml-ppx/ppxlib#202, @pitag-ha)

- Driver: take `-cookie` argument into account, also when the input is a
  binary AST (@pitag-ha, ocaml-ppx/ppxlib#209)

- `run_as_ppx_rewriter`: take into account the arguments
  `-loc-filename`, `apply` and `dont-apply` (ocaml-ppx/ppxlib#205, @pitag-ha)

- Location.Error: add functions `raise` and `update_loc`
  (ocaml-ppx/ppxlib#205, @pitag-ha)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0