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

[1.9] Wrong parameters parse for method signatures with default values

    Details

    • Type: Bug Bug
    • Status: Reopened Reopened
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: JRuby 1.5.6, JRuby 1.6.7
    • Fix Version/s: None
    • Component/s: Parser, Ruby 1.9.2
    • Labels:
      None
    • Number of attachments :
      0

      Description

      The new method signature causes MiniTest doesn't handle default arguments properly. I've reduced the issue to this code:

      require 'minitest/unit'
      
      module Foo
        include MiniTest::Assertions
      
        def assert(test, msg = (nomsg = true; nil))
          super
        end
      end
      
      include Foo
      
      assert 'foo' == '', 'expected blank'
      

      The expected output is:

      `assert': expected blank (MiniTest::Assertion)
      

      but I get the MiniTest default message:

      `assert': Failed assertion, no message given. (MiniTest::Assertion)
      

      The signature of the assert above is the same that TestUnit has for Ruby 1.9 and that causes ActiveSupport tests fail:

      https://github.com/jruby/jruby/blob/master/lib/ruby/1.9/test/unit/assertions.rb#L13

      If I remove the "nomsg = true" parameter it works fine.

        Activity

        Hide
        David Calavera added a comment -

        That's true, perfect.

        Show
        David Calavera added a comment - That's true, perfect.
        Hide
        Thomas E Enebo added a comment -

        We won't be getting to this refactoring for 1.6.0RC2. Marking 1.6.1.

        Show
        Thomas E Enebo added a comment - We won't be getting to this refactoring for 1.6.0RC2. Marking 1.6.1.
        Hide
        Charles Oliver Nutter added a comment -

        Still the same behavior as of JRuby master and jruby-1_6 today.

        Show
        Charles Oliver Nutter added a comment - Still the same behavior as of JRuby master and jruby-1_6 today.
        Hide
        Charles Oliver Nutter added a comment -

        Good news...the new IR stuff handles this one correctly

        system ~/projects/jruby $ ruby1.9.3 tmp/default_junk.rb 
        1
        2
        
        system ~/projects/jruby $ jruby -X-CIR tmp/default_junk.rb 
        1
        2
        

        So if the plan is to move to IR for everything, this will eventually be fixed that way

        Show
        Charles Oliver Nutter added a comment - Good news...the new IR stuff handles this one correctly system ~/projects/jruby $ ruby1.9.3 tmp/default_junk.rb 1 2 system ~/projects/jruby $ jruby -X-CIR tmp/default_junk.rb 1 2 So if the plan is to move to IR for everything, this will eventually be fixed that way
        Hide
        Charles Oliver Nutter added a comment -

        Still broken in 1.7, but won't be addressed until after 1.7.0 final.

        system ~/projects/jruby $ jruby -X-C test.rb
        1
        nil
        
        system ~/projects/jruby $ jruby test.rb
        1
        4
        
        Show
        Charles Oliver Nutter added a comment - Still broken in 1.7, but won't be addressed until after 1.7.0 final. system ~/projects/jruby $ jruby -X-C test.rb 1 nil system ~/projects/jruby $ jruby test.rb 1 4

          People

          • Assignee:
            Thomas E Enebo
            Reporter:
            David Calavera
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: