Repository navigation
rb_check_funcall reads a user method_missing's default miss as not callable, so the try_convert/Integer/Float conversions answer nils (fixes #152) - #157
Open
jiro-by-nori[bot] wants to merge 1 commit into
Conversation
…lable (issue #152) `__conv_callable?` answered true for every name once the class had a user `method_missing`, so `__check_convert` called the name and let the `NoMethodError` from `super` escape. CRuby's `check_funcall_missing` rescues that raise and answers `Qundef`, so `String.try_convert`/`Array.try_convert` return nil, `Integer`/`Float` reach their `can't convert X into Y`, and `Array` reaches its `to_a` fallback. The reading is per-arm: a user `respond_to?` or `respond_to_missing?` claim keeps CRuby's re-raise, a `NoMethodError` from a real method still escapes, and an answered nil stays distinct from a miss for `#to_i gives NilClass` and `no implicit conversion`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #152.
__conv_callable?answered "callable" for every name as soon as the receiver's class had a usermethod_missing.__check_convertthen called the name unguarded, so theNoMethodErrorfrom a handler that ends insuperescaped where CRuby answersnil.CRuby's
check_funcall_missingcalls the user handler underrb_rescue2(... rb_eNoMethodError)and reads that raise as its default miss (Qundef). The new__conv_callreproduces the reading, and — because the reading is per-arm — keeps the neighbouring rules intact:NoMethodErrorinside escapesrespond_to?orrespond_to_missing?claim, with a usermethod_missingbehind itNoMethodErrorescapes (check_funcall_failedre-raises)method_missingwith no claimNoMethodErroris the default miss:[false, nil][false, nil]calledis kept apart fromvalueso an answered nil still names its class (#to_i gives NilClass,#to_ary gives NilClass) while a miss reachesno implicit conversion/can't convert X into Y.Call sites updated:
__check_convert—String.try_convert,Array.try_convert,Kernel#Array'sto_afallback, and theto_strprobe inKernel#Integer;__to_integer/Kernel#Float— usecalledso a miss falls through tointo Integer/into Floatinstead of namingNilClass;__to_array_type—Array#+/#concatnow sayno implicit conversionfor the same miss.The generated
Prelude.lean/PreludeJson.leanaremake genoutput.Test plan
make check— ALL CHECKS PASSED (build, every proof book, soundness, comparator, desugarer, unit tests, conformance, docs).make check-not-weakened— CHECKS NOT WEAKENED.make conformance—ran 1287,agree 1087(baseline ≥1087),sut_unsupported 194(≤194),disagree 0; regressions and tier3 agree.difftest/corpus/regressions/conversion-method-missing.rb(statusfixed, filed by hand) pins the issue's table plus the claim/real-method/answered-nil arms; the tier reports agree.bin/ruby-lean --compareon the issue's table (model and CRuby 4.0.5 now print the same):Authored by Jiro, an autonomous agent: the code and this description.