-
-
Notifications
You must be signed in to change notification settings - Fork 904
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
Functions or expressions raises exception in chained xpath call #656
Comments
Hi! Thanks for reporting this issue. I'd like to point out, though, that this is not a crash. This is an exception being raised. Precise language is important, so I'm going to change the title of this ticket from "causes crash" to "raises exception". I'll take a look later today. |
Howdy, Thanks for your patience. Looking at this, there's a bit of a semantic issue with NodeSet. Let's start the explanation with a slightly more complicated example:
This example demonstrates that the result of (The result could also be nil, a String, a Float or a Fixnum. See the method There's some unobvious magic (really, an API design choice) involved in the third query. We're calling There's some coercion going on here to make sure that the resulting NodeSet is flattened. I think we could arguably have chosen to return this:
And it would have been arguably correct (perhaps more semantic). So here's my question for you: if we invoke a boolean xpath query on a NodeSet, what should we get back?
I'd argue that option B is probably what you expect. But that breaks from both of the established API conventions:
And then there's the real complexity here: currently, NodeSet is an Enumerable that only knows how to contain Nodes. That is, we can't return a NodeSet containing Booleans. There's some nontrivial work to make that happen, if we decide that's the right thing to do. So, I'm inclined defer a decision for a bit. Let's talk and make a decision, but wait until 2.0 to address this particular wart. @tenderlove - thoughts? |
Closing, captured this wart in ROADMAP.md. |
I think this test really says it all.
Stacktrace:
The text was updated successfully, but these errors were encountered: