Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Kernel#pretty_inspect looks to unexpected behavior in Hash objects. #276

Closed
kachick opened this Issue Aug 31, 2012 · 4 comments

Comments

Projects
None yet
3 participants
Contributor

kachick commented Aug 31, 2012

I noticed the following behavior when using "pry".

require 'pp'

hash = {}
hash[:key] = true
print hash.pretty_inspect

MRI/YARV

ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]

{:key=>true}

JRuby

jruby 1.7.0.preview2 (1.9.3p203) 2012-08-31 aeef1b8 on Java HotSpot(TM) 64-Bit Server VM 1.6.0_33-b03-424-11M3720 [darwin-x86_64]

{[:key, true]=>nil}
Owner

headius commented Aug 31, 2012

Another case of 1.9 block arguments failing to spread out properly, I would guess.

@tychobrailleur tychobrailleur added a commit to tychobrailleur/jruby that referenced this issue Sep 9, 2012

@tychobrailleur tychobrailleur Fix for issue #276
This commit fixes issue #276 which is a regression introduced by
http://jira.codehaus.org/browse/JRUBY-6729.  The bug was caused by a erroneous
behavour when yielding splat for a block of arity of one: MRI doesn't unsplat
the passed value, whilst jruby was.

See GH-276_yield_splat_behaviour_causes_pp_to_break.rb for details on behaviour
a2c6561
Contributor

tychobrailleur commented Sep 17, 2012

Hi, I hit this issue again today. Any chance of getting this pull request merged? #293
Thanks! (=

@headius headius added a commit that referenced this issue Sep 18, 2012

@headius headius Additional fix to go with #276 and its fix #293.
* Compiler needed the same logic.
* Invalid block needs to be checked or arity().getValue will NPE.
da2a9dd
Contributor

tychobrailleur commented Sep 18, 2012

Thanks for spending time on this, @headius!

@prathamesh-sonpatki prathamesh-sonpatki pushed a commit to prathamesh-sonpatki/jruby that referenced this issue Sep 18, 2012

@tychobrailleur tychobrailleur + Prathamesh Sonpatki Fix for issue #276
This commit fixes issue #276 which is a regression introduced by
http://jira.codehaus.org/browse/JRUBY-6729.  The bug was caused by a erroneous
behavour when yielding splat for a block of arity of one: MRI doesn't unsplat
the passed value, whilst jruby was.

See GH-276_yield_splat_behaviour_causes_pp_to_break.rb for details on behaviour
615e3a4

@prathamesh-sonpatki prathamesh-sonpatki pushed a commit to prathamesh-sonpatki/jruby that referenced this issue Sep 18, 2012

@headius headius + Prathamesh Sonpatki Additional fix to go with #276 and its fix #293.
* Compiler needed the same logic.
* Invalid block needs to be checked or arity().getValue will NPE.
dc19d5d

@prathamesh-sonpatki prathamesh-sonpatki pushed a commit to prathamesh-sonpatki/jruby that referenced this issue Sep 21, 2012

@tychobrailleur tychobrailleur + Prathamesh Sonpatki Fix for issue #276
This commit fixes issue #276 which is a regression introduced by
http://jira.codehaus.org/browse/JRUBY-6729.  The bug was caused by a erroneous
behavour when yielding splat for a block of arity of one: MRI doesn't unsplat
the passed value, whilst jruby was.

See GH-276_yield_splat_behaviour_causes_pp_to_break.rb for details on behaviour
55d17b2

@prathamesh-sonpatki prathamesh-sonpatki pushed a commit to prathamesh-sonpatki/jruby that referenced this issue Sep 21, 2012

@headius headius + Prathamesh Sonpatki Additional fix to go with #276 and its fix #293.
* Compiler needed the same logic.
* Invalid block needs to be checked or arity().getValue will NPE.
a0441ff
Contributor

tychobrailleur commented Sep 29, 2012

I am getting this error again, and tests show regression:

➈❸ greystones:~/dev/jruby (master)$ ./bin/jruby -S rspec spec/regression/GH-276_yield_splat_behaviour_causes_pp_to_break.rb 
..FFF

Failures:

  1) yield splat yields one value when block has two arguments and passed one
     Failure/Error: first_value.should == "a"
       expected: "a"
            got: ["a"] (using ==)
     # ./spec/regression/GH-276_yield_splat_behaviour_causes_pp_to_break.rb:36:in `(root)'

  2) yield splat yields two values when block has two arguments and passed two
     Failure/Error: first_value.should == "a"
       expected: "a"
            got: ["a", "b"] (using ==)
     # ./spec/regression/GH-276_yield_splat_behaviour_causes_pp_to_break.rb:44:in `(root)'

  3) yield splat yields two values when block has two arguments and passed three
     Failure/Error: first_value.should == "a"
       expected: "a"
            got: ["a", "b", "c"] (using ==)
     # ./spec/regression/GH-276_yield_splat_behaviour_causes_pp_to_break.rb:52:in `(root)'

Finished in 0.021 seconds
5 examples, 3 failures

Failed examples:

rspec ./spec/regression/GH-276_yield_splat_behaviour_causes_pp_to_break.rb:32 # yield splat yields one value when block has two arguments and passed one
rspec ./spec/regression/GH-276_yield_splat_behaviour_causes_pp_to_break.rb:40 # yield splat yields two values when block has two arguments and passed two
rspec ./spec/regression/GH-276_yield_splat_behaviour_causes_pp_to_break.rb:48 # yield splat yields two values when block has two arguments and passed three
➈❸ greystones:~/dev/jruby (master)$ ./bin/jruby -I"lib:test" test/externals/ruby1.9/test_pp.rb -n "test_hash_with_boolean_value"
Run options: -n test_hash_with_boolean_value

# Running tests:

F

Finished tests in 0.054000s, 18.5185 tests/s, 18.5185 assertions/s.

  1) Failure:
test_hash_with_boolean_value(PPTestModule::PPCycleTest) [test/externals/ruby1.9/test_pp.rb:143]:
<"{:b=>true}\n"> expected but was
<"{[:b, true]=>nil}\n">.

1 tests, 1 assertions, 1 failures, 0 errors, 0 skips

Pull request to follow.

@headius headius closed this in b62b54d Sep 29, 2012

@headius headius added a commit that referenced this issue Sep 29, 2012

@headius headius Merge pull request #324 from tychobrailleur/gh276
Fix #276. For good.
46399a1

@prathamesh-sonpatki prathamesh-sonpatki added a commit to prathamesh-sonpatki/jruby that referenced this issue Dec 3, 2012

@tychobrailleur @prathamesh-sonpatki tychobrailleur + prathamesh-sonpatki Fix #276. f42f7a1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment