Top level yields are invalid Ruby on files, but are valid on eval.
They exist on ERB files, and since those files are evaluated no written to disk they are fine.
We can tell Prism to parse the code using the eval context by passing scopes: [[]] to parse, but since are are using the Prism::Translation::Parser class we have no way to do that.
A PR was proposed to Prism to always consider the code as being evaluated in the Parser translation.
For now, we can safely ignore that class of error by overriding the valid_error? method on our own parser.
Top level yields are invalid Ruby on files, but are valid on
eval
.They exist on ERB files, and since those files are evaluated no written to disk they are fine.
We can tell Prism to parse the code using the eval context by passing
scopes: [[]]
toparse
, but since are are using thePrism::Translation::Parser
class we have no way to do that.A PR was proposed to Prism to always consider the code as being evaluated in the
Parser
translation.For now, we can safely ignore that class of error by overriding the
valid_error?
method on our own parser.Fixes #400.