Skip to content

Fixes language specs involving blocks/yield#8014

Merged
enebo merged 5 commits intojruby:masterfrom
enebo:to_ary_fix
Nov 16, 2023
Merged

Fixes language specs involving blocks/yield#8014
enebo merged 5 commits intojruby:masterfrom
enebo:to_ary_fix

Conversation

@enebo
Copy link
Member

@enebo enebo commented Nov 16, 2023

The issue is if we try to call to_ary during block dispatch and respond_to? does not exist on the object it should return the original object. We were failing because we rightly called method_missing but because m_m did not handle to_ary we just raised NoMethodError and not the original object.

This also fixes improper spreading of a single value array into a proc which only has optargs.

Some very minor error handling for uncommon syntax.

The issue is if we try to call to_ary during block dispatch and
respond_to? does not exist on the object it should return the
original object.  We were failing because we rightly called
method_missing but because m_m did not handle to_ary we just
raised NoMethodError and not the original object.
@enebo enebo added this to the JRuby 9.4.6.0 milestone Nov 16, 2023
This is a followup to previous commit and also reduces the number
of respond_to? calls by making a new TypeConverter method:
convertToTypeUnchecked.  This method already knows the conversion
method exists so we do not check it again.
In the presence of only opt-args a single array value will spread
but we have not.  I adjusted our isSpreadable method to "form-fit"
to make everything pass.  An interesting note that part of my
fit was to realize kwrest was special and not in spreadable but
did happen to see it in the same code JIT had.  both interp
and JIT both call into the same method now.
This lead to discovering a bug in a method which would find
first non-closure IRScope (it did the opposite).  Weirdly, the
main consumer rolled with this mistake.  Corrected caller and
the method which in turn removed the yield from being a runtime
error into a Syntax error.
@enebo enebo changed the title Fixes language spec involving block calling #to_ary Fixes language specs involving blocks/yield Nov 16, 2023
@enebo enebo merged commit 34b9e94 into jruby:master Nov 16, 2023
@enebo enebo deleted the to_ary_fix branch November 16, 2023 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant