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

🔇 Suppress diagnostics caused by already reported errors #160

Open
kentookura opened this issue Oct 14, 2024 · 11 comments
Open

🔇 Suppress diagnostics caused by already reported errors #160

kentookura opened this issue Oct 14, 2024 · 11 comments

Comments

@kentookura
Copy link

In forester, we have a multiple preorders on source files generated by the different types of links that may be contained within a file.
When an error occurs, the final report produced by asai can be somewhat confusing, as the error that is reported last (meaning it is the most visible) can be the result of an error produced much earlier. For example, If A contains an error, evaluation of B will throws tree A not found.

   transcluded by
A -------------------> B

The final report will look something like this.

Error in A: not valid!
Error in B: A not found!

Now, this example is not too bad but it can quickly grow unwieldy and confusing if the most relevant error is somewhere in a long list of semi-spurious errors. It would be quite simple for me to write some heuristics that order and filter the errors according to some graph-theoretic criteria, but I haven't figured out if the Asai API supports manipulating the reports like this. Any pointers?

Thanks!

@favonia
Copy link
Contributor

favonia commented Oct 14, 2024

@kentookura The API calls the emit effect handler for each diagnostic, so you can intercept them and perform reordering or filtering. I'm happy to go back to the drawing board and add more functionality---we do not have to limit ourselves to the current API. Do you have any suggestion?

@favonia favonia changed the title Filtering/ordering the reported diagnostcs 🔀 Filtering/ordering the reported diagnostcs Oct 14, 2024
@kentookura
Copy link
Author

I will try to implement it using your suggestion and report back if I encounter any rough edges or blockers!

@favonia
Copy link
Contributor

favonia commented Oct 14, 2024

@kentookura The better design is to absorb what you plan to implement into the library. 😉

@kentookura
Copy link
Author

@favonia I think in order to generalize our use case to library code, Asai needs some notion of dependency or context such that it is possible to omit the diagnostics reported by one "file" (or some other unit of contiguous code) if it depends on some other piece of code that contains errors, or if it emitted inside a specific context. The nice thing about our use case is that it is somewhat clear when such a relationship exists, namely when transclusion fails due to the failure of the inner tree. I wonder what a general API for this might look like...

@kentookura
Copy link
Author

@favonia I don't quite understand how to do reordering: Say my goal is to reorder the diagnostics according to their severity. I can keep modifying a reference to a list in the handler, but I don't see how I can control what happens after all diagnostics have accumulated. What I want is to run the computation and accumulate state, and at the end use that state to compute an optimal error report.

@favonia
Copy link
Contributor

favonia commented Oct 14, 2024

@kentookura You need to explicitly access the state with all the accumulated diagnostics. The state should be made available after calling Reporter.run.

@favonia
Copy link
Contributor

favonia commented Oct 15, 2024

@kentookura I'm not sure about reordering diagnostics, but it seems trivial to implement some inefficient suppression. This can also be used to stop the same hint from being displayed, etc. The idea is to have a function Diagnostic.t -> bool that filter future diagnostics.

I'm not sure how to implement this efficiently, though. 🤔

@favonia favonia changed the title 🔀 Filtering/ordering the reported diagnostcs 🔇 Supress diagnostcs caused by already reported errors Oct 31, 2024
@favonia
Copy link
Contributor

favonia commented Oct 31, 2024

@kentookura I'm repurposing this issue for the common need I saw in mikeshulman/narya#24: suppressing useless diagnostics caused by already reported errors.

@favonia favonia changed the title 🔇 Supress diagnostcs caused by already reported errors 🔇 Suppress diagnostics caused by already reported errors Oct 31, 2024
@favonia
Copy link
Contributor

favonia commented Oct 31, 2024

@kentookura @mikeshulman If we want a "universal" index type of "causes", what should it be? Or should we avoid such a "universal" type at all costs?

@kentookura
Copy link
Author

I am not quite sure what you mean and I think it depends on how such a type would be used in the API. My guess is that the API should not be centered around such a type in such a way as to constrain the manipulation of diagnostics. If the type simplifies the juggling of various diagnostics reported by various sources, then I am all for it.

@favonia
Copy link
Contributor

favonia commented Oct 31, 2024

@kentookura I meant, using your example, how would you write down "A" in some "global database" so that you know it has been reported when checking "B"?

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

No branches or pull requests

2 participants