Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Question about compiler plugin test development - what's a best practice to catch REPL errors? #20233

Unanswered
kincsescsaba asked this question in Compiler internals Q&A
Discussion options

Assumptions

Just so you know, I use a compiler plugin in the below examples related to REPL development.

This video https://www.youtube.com/watch?v=UpsRLbEHmik suggests that (see 15:00) a Compiler class is needed to test compiler plugins. I assume this class covers the whole process. Hence, there is no place to use other classes (e.g., PluginPhase) for this purpose. This class lets me hook an extra phase into the phases listing to make assertions on the current state of the tree under transformation, though it's not completely clear how this works. It's unclear how I should decide at which point I should insert the assertion.

I assume in case of an error, it's an anti-pattern to transform a tree; the preferable is reporting an error and returning the tree unchanged:

tree match
 case Select(_, selectedName) if selectedName.toString == "something to forbid" =>
 report.error("Error report")
 case _ =>
tree

Questions

As far as I understand, the above-mentioned video suggests assertions on the tree, but in case of an error report, the tree would be unchanged. How can I catch an error reporting, and where should I insert a handler for that (e.g., after which phase; is the Compiler class appropriate for that)?

You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

You might consider using https://github.com/scala/scala3/discussions or discord or forum.

You must be logged in to vote
1 reply
Comment options

soronpo Apr 19, 2024
Collaborator

Moved to discussions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Converted from issue

This discussion was converted from issue #20226 on April 19, 2024 03:00.

AltStyle によって変換されたページ (->オリジナル) /