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

Unexpected nil from SyntaxTree.parse #357

Closed
prikha opened this issue Mar 31, 2023 · 3 comments
Closed

Unexpected nil from SyntaxTree.parse #357

prikha opened this issue Mar 31, 2023 · 3 comments

Comments

@prikha
Copy link

prikha commented Mar 31, 2023

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?

@kddnewton
Copy link
Member

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.

@prikha
Copy link
Author

prikha commented Mar 31, 2023

@kddnewton can you share some details, is the "new" parser already out or in the making?

@kddnewton
Copy link
Member

The new parser is here: https://github.com/Shopify/yarp. The issue tracking its adoption is pinned and available here: #278.

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