Skip to content

Hash inspection not working as in MRI for sprintf %p #2161

@headius

Description

@headius

The test that's failing in mri/ruby/test_sprintf.rb:

  def test_hash
    options = {:capture=>/\d+/}
    assert_equal("with options {:capture=>/\\d+/}", sprintf("with options %p" % options))
  end

The failure:

ArgumentError: positional args mixed with named args
    org/jruby/RubyString.java:1221:in `%'
    /Users/headius/projects/jruby/test/mri/ruby/test_sprintf.rb:173:in `test_hash'

We do have code that raises this error around Sprintf.java:154 in Sprintf::Args#next, but I was not able to figure out the equivalent code in MRI (it doesn't seem to be there in the GETNEXTARG macro in sprintf.c nor in the logic for case 'p' in the main switch) nor does the test itself indicate where/when the change to sprintf was actually made.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions