rubinius/rubinius — pull request #1743 by LTe (2012-05-24 12:08:05+00:00)
Title: REXML::XPath - problem with 'and' in xpath

How to reproduce bug:

```ruby
require 'rexml/document'
require 'rexml/element'

@body = "test"
@xpath = "/testsuite[@tests='5' and @skipped='0' and @failures='0']"
@document = REXML::Document.new(@body)
REXML::XPath.match(@document, @xpath)
```

```
An exception occurred running rub.rb
undefined method `inject' on true:TrueClass. (NoMethodError)

Backtrace:
Kernel(TrueClass)#inject (method_missing) at kernel/delta/kernel.rb:81
REXML::XPathParser#expr at /home/lite/.rvm/rubies/rbx-head/lib/19/rexml/xpath_parser.rb:437
{ } in REXML::XPathParser#expr at /home/lite/.rvm/rubies/rbx-head/lib/19/rexml/xpath_parser.rb:302
{ } in Enumerable(Array)#each_with_index at kernel/common/enumerable19.rb:137
Array#each at kernel/bootstrap/array.rb:68
Enumerable(Array)#each_with_index at kernel/common/enumerable19.rb:136
REXML::XPathParser#expr at /home/lite/.rvm/rubies/rbx-head/lib/19/rexml/xpath_parser.rb:296
REXML::XPathParser#match at /home/lite/.rvm/rubies/rbx-head/lib/19/rexml/xpath_parser.rb:129
REXML::XPathParser#parse at /home/lite/.rvm/rubies/rbx-head/lib/19/rexml/xpath_parser.rb:60
REXML::XPath.match at /home/lite/.rvm/rubies/rbx-head/lib/19/rexml/xpath.rb:74
Object#__script__ at rub.rb:7
Rubinius::CodeLoader#load_script at kernel/delta/codeloader.rb:67
Rubinius::CodeLoader.load_script at kernel/delta/codeloader.rb:109
Rubinius::Loader#script at kernel/loader.rb:640
Rubinius::Loader#main at kernel/loader.rb:844
```

When developer uses 'and' many times in xpath then ```left``` variable (https://github.com/rubinius/rubinius/blob/master/lib/19/rexml/xpath_parser.rb#L437) is ```true``` so ```inject``` method will raise exeception.