8000 Metaquot: Embed errors in the AST instead of raising by Burnleydev1 · Pull Request #397 · ocaml-ppx/ppxlib · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Metaquot: Embed errors in the AST instead of raising #397

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 10 commits into from
Mar 22, 2023
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
unreleased
------------------

- multiple errors are now reported in `metaquot`. (#397, @burnleydev1)

- Add `Attribute.declare_with_attr_loc` (#396, @dvulakh)

- Add "ns" and "res" as reserved namespaces(#388, @davesnx)
Expand Down
15 changes: 12 additions & 3 deletions metaquot/ppxlib_metaquot.ml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ module Expr = Make (struct
assert_no_attributes attrs;
e
| _ ->
Location.raise_errorf ~loc:(loc_of_extension ext) "expression expected"
Ast_builder.Default.(
pexp_extension ~loc:(loc_of_extension ext)
(Location.error_extensionf ~loc:(loc_of_extension ext)
"expression expected"))
end)

module Patt = Make (struct
Expand All @@ -129,8 +132,14 @@ module Patt = Make (struct
match snd ext with
| PPat (p, None) -> p
| PPat (_, Some e) ->
Location.raise_errorf ~loc:e.pexp_loc "guard not expected here"
| _ -> Location.raise_errorf ~loc:(loc_of_extension ext) "pattern expected"
Ast_builder.Default.(
ppat_extension ~loc:e.pexp_loc
(Location.error_extensionf ~loc:e.pexp_loc "guard not expected here"))
| _ ->
Ast_builder.Default.(
ppat_extension ~loc:(loc_of_extension ext)
(Location.error_extensionf ~loc:(loc_of_extension ext)
"pattern expected"))
end)

let () =
Expand Down
0