-
Couldn't load subscription status.
- Fork 1.1k
Question about compiler plugin test development - what's a best practice to catch REPL errors? #20233
-
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)?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 1 reply
-
You might consider using https://github.com/scala/scala3/discussions or discord or forum.
Beta Was this translation helpful? Give feedback.
All reactions
-
Moved to discussions
Beta Was this translation helpful? Give feedback.