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

pattern match bug with internal array #2617

Closed
HoneyryderChuck opened this issue Mar 6, 2022 · 7 comments
Closed

pattern match bug with internal array #2617

HoneyryderChuck opened this issue Mar 6, 2022 · 7 comments

Comments

@HoneyryderChuck
Copy link
Contributor

Given truffleruby's ruby 3 support, a new codepath was unlocked in httpx test suite which surfaced what it seems like a parser bug.

This should also be easily reproducible just by copying the line with the pattern match (I did it using irb and it crashed the console).

@eregon
Copy link
Member

eregon commented Mar 7, 2022

Pattern matching is not implemented yet, that's why it's a SyntaxError.
It's currently tracked as part of #2453.
The main issue is it's a huge effort to update the parser, with no easy solution.
We're trying to figure out a better long term solution to keep the parser up-to-date with reasonable efforts (instead of copying+adapting thousands of lines manually from JRuby or CRuby).

@eregon
Copy link
Member

eregon commented Mar 7, 2022

Does httpx support Ruby <= 2.6 which doesn't have pattern matching? It seems so from the gemspec & CI files.
What does it use to detect if pattern matching is supported?
The best way is probably to check one by trying to eval some pattern matching and if that's SyntaxError -> not supported.

@HoneyryderChuck
Copy link
Contributor Author

HoneyryderChuck commented Mar 7, 2022

Does httpx support Ruby <= 2.6

It does.

The detection is only relevant for tests, and is based on ruby version. For the library, the extensions are fairly safe even if pattern matching wouldn't be supported.

I guess I can use the eval as you suggested for now. It just feels a bit odd not going with the ruby version, as for other rubies it's a pretty reliable "feature discovery" tool (although I understand the issues related with the parser).

@eregon
Copy link
Member

eregon commented Mar 7, 2022

In general feature detection is much better than checking RUBY_VERSION (also applies to C APIs BTW), RUBY_VERSION should IMHO only be used when there is no other reasonable way (very rare).
Since TruffleRuby is released every 3 months, it's always possible some features of a CRuby version are not implemented, and so feature detection is important.

@HoneyryderChuck
Copy link
Contributor Author

Sorry, I meant ruby version is pretty reliable if I can't do feature detection (i.e. defined?(NewClass) or .respond_to?(:fancy_new_method)) :-) . I guess there isn't a great way to feature-detect new syntax, besides your suggestion, so I'll take it.

@HoneyryderChuck
Copy link
Contributor Author

Applied the patch, should this be kept open?

@eregon
Copy link
Member

eregon commented Mar 31, 2022

Let's close this, we have other issues to track pattern matching support, and until then the SyntaxError is expected.

@eregon eregon closed this as completed Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants