JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-6729

[1.9] block argument to yield method is not correctly pass to a block. -- pp's seplist method

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.7.0.pre1
    • Fix Version/s: JRuby 1.7.0.pre2
    • Component/s: Interpreter
    • Labels:
      None
    • Number of attachments :
      0

      Description

      The bug causes an error form Nokogiri's 1.9 mode. Also, the bug is reported in issue#657, https://github.com/sparklemotion/nokogiri/issues/657 .

      Please look at seplist method in lib/ruby/1.9/pp.rb, line 214-225. A given argument as "list" looks like this:

      [[:name, "html"]]

      This turns out *v should be [:name, "html"] . In seplist method, the value of *v is a correct one, [:name, "html"]. However, in the given block, (the first) argument is :name only. The "yield" method, line#223, is suspicious.

      Nokogiri uses seplist method in lib/nokogiri/xml/pp/node.rb, https://github.com/sparklemotion/nokogiri/blob/master/lib/nokogiri/xml/pp/node.rb, line#36-48.

      On JRuby 1.9, "v" in Nokogiri's pretty_print method, line#37 in https://github.com/sparklemotion/nokogiri/blob/master/lib/nokogiri/xml/pp/node.rb , isn't an Array and doesn't have first method. Then, an error is thrown from here.

        Activity

        Hide
        Yoko Harada added a comment -

        Just my guess, org.jruby.ast.Yield19Node.interpret() method might do something wrong. In switch statement, args.getNodeType() matched to "case SPLATNODE" against [:name, "html"] .

        This pp issue doesn't exist on 1.8 mode.

        Show
        Yoko Harada added a comment - Just my guess, org.jruby.ast.Yield19Node.interpret() method might do something wrong. In switch statement, args.getNodeType() matched to "case SPLATNODE" against [:name, "html"] . This pp issue doesn't exist on 1.8 mode.
        Hide
        Thomas E Enebo added a comment -

        Yoko, can you try running with -X-CIR? I think IR does this correctly and I guess it would be useful to know. Also reducing this to a small snippet would also be helpful.

        Show
        Thomas E Enebo added a comment - Yoko, can you try running with -X-CIR? I think IR does this correctly and I guess it would be useful to know. Also reducing this to a small snippet would also be helpful.
        Hide
        Cyprian Kowalczyk added a comment -

        I've recently came across the problems with PP resulting in the following error

        #(Document:0x2366 {NoMethodError: undefined method `first' for :name:Symbol
        from /Users/cyp/.rvm/gems/jruby-1.6.7.2@global/gems/nokogiri-1.5.3-java/lib/nokogiri/xml/pp/node.rb:37:in `pretty_print'

        Show
        Cyprian Kowalczyk added a comment - I've recently came across the problems with PP resulting in the following error #(Document:0x2366 {NoMethodError: undefined method `first' for :name:Symbol from /Users/cyp/.rvm/gems/jruby-1.6.7.2@global/gems/nokogiri-1.5.3-java/lib/nokogiri/xml/pp/node.rb:37:in `pretty_print'
        Hide
        Yoko Harada added a comment -

        Tom, below is a simplified example:

        require 'pp'
        
        p = PP.new
        ary = [[:key, "value"]]
        
        p.seplist(ary) {|e| p e}
        

        JRuby prints out:

        :key
        

        Ruby 1.9.3 prints out

        [:key, "value"]
        

        BTW, what is -X-CIR option? I tried using above simple code, but I didn't see any difference with and without option.

        Show
        Yoko Harada added a comment - Tom, below is a simplified example: require 'pp' p = PP.new ary = [[:key, "value"]] p.seplist(ary) {|e| p e} JRuby prints out: :key Ruby 1.9.3 prints out [:key, "value"] BTW, what is -X-CIR option? I tried using above simple code, but I didn't see any difference with and without option.
        Hide
        Yoko Harada added a comment -

        I pushed the fix in rev. 7997577 . This fixes my snippet here, Nokogiri's 1.9 test and reported issue to Nokogiri project.

        Show
        Yoko Harada added a comment - I pushed the fix in rev. 7997577 . This fixes my snippet here, Nokogiri's 1.9 test and reported issue to Nokogiri project.
        Hide
        Thomas E Enebo added a comment -

        Resolving. All tests pass! Thanks Yoko...I hope this is the last error.

        Show
        Thomas E Enebo added a comment - Resolving. All tests pass! Thanks Yoko...I hope this is the last error.

          People

          • Assignee:
            Yoko Harada
            Reporter:
            Yoko Harada
          • Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: