Skip to content

Commit

Permalink
Make Context_free.map_top_down embed_errors arg optional
Browse files Browse the repository at this point in the history
This extra argument that was added in ocaml-ppx#453 caused breakage
in `ocsigen-i18n` that was using `Context_free.map_top_down`.
Although it's undocumented, this function is still part of the public
API. Adding an extra optional argument is not strictly speaking
non-breaking but is good enough of an effort considering the status
of this function and in particular, the fact that it only has a single
public external user for which it prevents breakage.

Signed-off-by: Nathan Rebours <[email protected]>
  • Loading branch information
NathanReb committed Feb 2, 2024
1 parent 7c46d34 commit 6084599
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
unreleased
-------------------

- Add an optional `embed_errors` argument to `Context_free.map_top_down` that
controls how to deal with exceptions thrown by context-free rules.
(#<PR_NUMBER>, @NathanReb)

- Fix `Longident.parse` so it properly handles unparenthesized dotted operators
such as `+.` or `*.`. (#111, @rgrinberg, @NathanReb)

Expand Down
3 changes: 2 additions & 1 deletion src/context_free.ml
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,8 @@ module Expect_mismatch_handler = struct
end

class map_top_down ?(expect_mismatch_handler = Expect_mismatch_handler.nop)
?(generated_code_hook = Generated_code_hook.nop) rules ~embed_errors =
?(generated_code_hook = Generated_code_hook.nop) ?(embed_errors = false) rules
=
let hook = generated_code_hook in

let special_functions =
Expand Down
2 changes: 1 addition & 1 deletion src/context_free.mli
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ class map_top_down :
Expect_mismatch_handler.t (* default: Expect_mismatch_handler.nop *) ->
?generated_code_hook:
Generated_code_hook.t (* default: Generated_code_hook.nop *) ->
?embed_errors:bool ->
Rule.t list ->
embed_errors:bool ->
object
inherit Ast_traverse.map_with_expansion_context_and_errors
end

0 comments on commit 6084599

Please sign in to comment.