Skip to content
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

Driver: Multiple errors can be reported. #447

Merged
merged 8 commits into from
Jan 8, 2024

Conversation

Burnleydev1
Copy link
Contributor

No description provided.

@Burnleydev1 Burnleydev1 marked this pull request as ready for review July 11, 2023 20:15
Copy link
Collaborator

@panglesd panglesd left a comment

Choose a reason for hiding this comment

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

Thanks @Burnleydev1!

I left some comments, but it looks good!

Before merging this PR, I will write an issue explaining why we need your changes: most of the discussion happened offline, and it is good to have a log of the reason of the change.

CHANGES.md Outdated Show resolved Hide resolved
src/driver.ml Outdated Show resolved Hide resolved
src/driver.ml Outdated Show resolved Hide resolved
src/driver.ml Outdated Show resolved Hide resolved
src/driver.ml Outdated Show resolved Hide resolved
src/driver.ml Show resolved Hide resolved
src/driver.ml Outdated Show resolved Hide resolved
test/driver/exception_handling/run.t Outdated Show resolved Hide resolved
[%%ocaml.error "A second located error in a whole file transform"]
[%%ocaml.error "SHOULD APPEAR LAST"]
type a = int
type b = int[@@deriving deriver_raised_exception]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe a new impl.ml should be created, without this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello @panglesd, please I do not understand how to do this, do I add a new multiple_whole_file.ml and add its exe line to the dune file?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The file impl.ml is defined at lines 113 and 114 of this file. Such a file is created once per example, overwriting the previous one. For instance an impl.ml file was already created at line 84-86, overwritten at line 113-114.

It would be ideal to overwrite impl.ml one more time to have the file tailored to the example (e.g., without a mention to deriver_raised_exception)

Copy link
Collaborator

@panglesd panglesd left a comment

Choose a reason for hiding this comment

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

I noticed that we also need an update to the documentation for this PR!

At least the part on handling errors should be updated to reflect the new behaviour.

Copy link
Collaborator

@NathanReb NathanReb left a comment

Choose a reason for hiding this comment

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

This looks good to me!

I have only one concern regarding documentation. I think the good practice section should only contain the recommended way to deal with errors to avoid confusion. It dives pretty deep into how we handle raised exceptions and I don't think this is useful for ppx authors.

Specifying this behaviour is important but I think it should probably live elsewhere for clarity's sake.

@panglesd what should be done regarding #457? There's a bit of documentation here and I think it will conflict with your work. I'm happy to cut out the documentation changes so we can merge this and discuss how to best document the behaviour elsewhere.

CHANGES.md Outdated Show resolved Hide resolved
@NathanReb
Copy link
Collaborator

@Burnleydev1 do you want to take care of rebasing and fixing the last bits? I'm happy to take care of it if you don't have time for this.

@panglesd
Copy link
Collaborator

panglesd commented Jan 8, 2024

I'm happy to cut out the documentation changes so we can merge this and discuss how to best document the behaviour elsewhere.

I agree! Also, it would not really make sense to write documentation separately for this PR and #453, it's more efficient to do it once for both (e.g. in #457).

Signed-off-by: Nathan Rebours <[email protected]>
@NathanReb
Copy link
Collaborator

I just rebased and dropped the documentation changes. This should be good to go!

@panglesd
Copy link
Collaborator

panglesd commented Jan 8, 2024

Great, thanks @NathanReb!

Thanks a lot @Burnleydev1 for your work!

@panglesd panglesd merged commit 1518afc into ocaml-ppx:main Jan 8, 2024
5 checks passed
NathanReb added a commit to NathanReb/opam-repository that referenced this pull request Feb 1, 2024
CHANGES:

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

- raising an exception does no longer cancel the whole context free phase(ocaml-ppx/ppxlib#453, @Burnleydev1)

- Sort embedded errors that are appended to the AST by location so the compiler
  reports the one closer to the beginning of the file first. (ocaml-ppx/ppxlib#463, @NathanReb)

- Update `Attribute.get` to ignore `loc_ghost`. (ocaml-ppx/ppxlib#460, @ceastlund)

- Add API to manipulate attributes that are used as flags (ocaml-ppx/ppxlib#408, @dianaoigo)

- Update changelog to use ISO 8061 date format: YYYY-MM-DD. (ocaml-ppx/ppxlib#445, @ceastlund)

- Replace `Caml` with `Stdlib`. (ocaml-ppx/ppxlib#427, @ceastlund)

- When a transformation raises, the last valid AST is used as input to the upcoming
  transformations. All such errors are collected and appended as
  extension nodes to the final AST (ocaml-ppx/ppxlib#447, @Burnleydev1)

- Fix a small mistake in the man pages: Embededding errors is done by default with
  `-as-pp`, not with `-dump-ast` (ocaml-ppx/ppxlib#464, @pitag-ha)

- Set appropriate binary mode when writing to `stdout` especially for Windows
  compatibility. (ocaml-ppx/ppxlib#466, @jonahbeckford)
NathanReb added a commit to NathanReb/opam-repository that referenced this pull request Feb 5, 2024
CHANGES:

- Add an optional `embed_errors` argument to `Context_free.map_top_down` that
  controls how to deal with exceptions thrown by context-free rules.
  (ocaml-ppx/ppxlib#468, @NathanReb)

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

- raising an exception does no longer cancel the whole context free phase(ocaml-ppx/ppxlib#453, @Burnleydev1)

- Sort embedded errors that are appended to the AST by location so the compiler
  reports the one closer to the beginning of the file first. (ocaml-ppx/ppxlib#463, @NathanReb)

- Update `Attribute.get` to ignore `loc_ghost`. (ocaml-ppx/ppxlib#460, @ceastlund)

- Add API to manipulate attributes that are used as flags (ocaml-ppx/ppxlib#408, @dianaoigo)

- Update changelog to use ISO 8061 date format: YYYY-MM-DD. (ocaml-ppx/ppxlib#445, @ceastlund)

- Replace `Caml` with `Stdlib`. (ocaml-ppx/ppxlib#427, @ceastlund)

- When a transformation raises, the last valid AST is used as input to the upcoming
  transformations. All such errors are collected and appended as
  extension nodes to the final AST (ocaml-ppx/ppxlib#447, @Burnleydev1)

- Fix a small mistake in the man pages: Embededding errors is done by default with
  `-as-pp`, not with `-dump-ast` (ocaml-ppx/ppxlib#464, @pitag-ha)

- Set appropriate binary mode when writing to `stdout` especially for Windows
  compatibility. (ocaml-ppx/ppxlib#466, @jonahbeckford)
nberth pushed a commit to nberth/opam-repository that referenced this pull request Jun 18, 2024
CHANGES:

- Add an optional `embed_errors` argument to `Context_free.map_top_down` that
  controls how to deal with exceptions thrown by context-free rules.
  (ocaml-ppx/ppxlib#468, @NathanReb)

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

- raising an exception does no longer cancel the whole context free phase(ocaml-ppx/ppxlib#453, @Burnleydev1)

- Sort embedded errors that are appended to the AST by location so the compiler
  reports the one closer to the beginning of the file first. (ocaml-ppx/ppxlib#463, @NathanReb)

- Update `Attribute.get` to ignore `loc_ghost`. (ocaml-ppx/ppxlib#460, @ceastlund)

- Add API to manipulate attributes that are used as flags (ocaml-ppx/ppxlib#408, @dianaoigo)

- Update changelog to use ISO 8061 date format: YYYY-MM-DD. (ocaml-ppx/ppxlib#445, @ceastlund)

- Replace `Caml` with `Stdlib`. (ocaml-ppx/ppxlib#427, @ceastlund)

- When a transformation raises, the last valid AST is used as input to the upcoming
  transformations. All such errors are collected and appended as
  extension nodes to the final AST (ocaml-ppx/ppxlib#447, @Burnleydev1)

- Fix a small mistake in the man pages: Embededding errors is done by default with
  `-as-pp`, not with `-dump-ast` (ocaml-ppx/ppxlib#464, @pitag-ha)

- Set appropriate binary mode when writing to `stdout` especially for Windows
  compatibility. (ocaml-ppx/ppxlib#466, @jonahbeckford)
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.

3 participants