-
Notifications
You must be signed in to change notification settings - Fork 5
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
Embed errors in the generated AST instead of raising. #27
Comments
Hello! Giving this issue a shot for the Outreachy contribution period of Oct 2021. |
Hi @NathanReb, I am an Outreachy intern willing to contribute to |
Hi @desirekaleba, nice that you want to contribute to OCaml! Do you already have OCaml up and running on your computer? |
Cool! So yes: perfect to start working on an issue now! Which one do you prefer? This one here or the one on |
Just for future reference: @desirekaleba is working on the |
Hi @pitag-ha ! I am Anubhuti, an Outreachy applicant. I would like to work on this issue. Can this be assigned to me, please? |
Hey @Anu-123-gif, welcome! Do you already have ocaml up and running? |
@pitag-ha Yes, I have ocaml up and running and I have also cloned this repository. I would really appreciate it if you could help me with the next steps, thanks! |
Cool! So yes: you can go ahead and work on this issue.
The next steps will be to improve the error reporting as asked for in the issue description and, once that's done, to open a PR. There's a very detailed new section for the Ppxlib manual (not merged yet) about ppx error reporting, which explains exactly what's asked for in this issue: https://github.com/ocaml-ppx/ppxlib/pull/318/files Let me know if you have any further questions! |
Thanks! I'll reach out to you with any additional questions that I have along the way. |
Hey @pitag-ha, so far I've understood that the errors are raised using |
Hi @Anu-123-gif -- you're right that the main task is to move from raising errors (like the payload example you gave), to errors as embedded nodes in the AST. You're also right to look at Now the question is how to embed the errors: pitag shared with you a link that's a PR diff that is in something similar to markdown. I recommend you copy that into a md editor to be able to read it more easily. At the start of that documentation, they list functions that raise errors and the corresponding function that would embed the error instead. The most relevant one is The documentation pitag linked above explains the usage of |
Hey @ayc9 , thank you for your response. I had read the Pr linked by pitag but now after the information you shared it'll be more clear to me. I'll start working on that and get back to you. Thanks again! |
Hey, @ayc9 @pitag-ha I'm having a little trouble understanding how to test the changes I have made. Basically, I have figured out where I'm supposed to write the command |
Hi @Anu-123-gif -- after making the changes and running The first thing to check is if the new things in green are indeed the changes you want (in this case, you want to see Let me know if this makes sense! Edit: You can check out this page to read more about how the tests work! |
Hey @ayc9 thanks for the reply. Update: I went through the intro to OCaml ppx ecosystem and now I understand the workings of each section clearly. I have now started working on the issue with more detailed knowledge. My doubt is cleared now :) |
Hey @ayc9, while going throught the PR linked by pitag I found a piece of code |
This is saying that:
The documentation then goes on to talk about whole-file rewriters and context free transformations, but you can skip those details because I don't think they are needed here. For your case specifically, you should search the repo for places where errors are raised ( After you make some changes, you can try |
Thank you for your response @ayc9! |
This error is saying the compiler doesn't know where to get the function from. |
Thanks a lot @ayc9 it worked when I used this piece of code. I just have one doubt since we don't want to |
Hey @Anu-123-gif, nice to see that you're making progress!
I'm not sure I understand your question here, but let's see if the following helps: as a first step, I think it could help to simply not use the
Are you referring to |
Hey @pitag-ha! thank you for your reply. I had tried to directly embed the error commands as discussed with aya above. However, doing this led to a lot of errors. For example: Another error which I can't rid of is
At the time I was using Thanks again! |
Hey @Anu-123-gif -- for the first set of errors: it looks like you are using a function As for the signature error mismatch: this is due to the change you made to Hope this helps you understand the compiler's error messages a bit better! |
Embedding errors directly into the AST using the special
[%ocaml.error "Some error msg"]
is the preferred way of reporting errors in ppxlib based ppx-es so it would be nice to migrate from raising throughLocation.raise_error*
to embedding errors directly.This would allow reporting several errors at once for a given ppx_yojson extension.
The text was updated successfully, but these errors were encountered: