Unexpected `nil` from `SyntaxTree.parse`
prikha opened this issue · comments
I've stumbled upon unexpected behaviour of SyntaxTree#parse
Actual behaviour:
SyntaxTree.parse('/*/') #=> nil
Expected behaviour:
SyntaxTree.parse('/*/') #=> SyntaxTree::Parser::ParseError
It's not a bug, but more of an inconsistent interface, I expect it to return either a Node
or raise an exception. And nil
just doesn't give any information. I suggest raising exception in case of parser.error?
I might consider it in the future on a major version, but that interface would be a breaking change. Right now it's expected that it could return nil
if parsing failed, which matches ripper's behavior.
In the future this won't matter, because when we switch to the new parser it's going to always return something.
@kddnewton can you share some details, is the "new" parser already out or in the making?
The new parser is here: https://github.com/Shopify/yarp. The issue tracking its adoption is pinned and available here: #278.