Repository navigation
A builtin's Integer or Float answer fills a dispatch slot that holds its nil - #8472
Conversation
…its nil A call on a boxed value whose class has a reader that can answer nil, named like a builtin's Integer or Float method (pid, to_i, length, utime, ...), dispatches over the class and the builtin. The call is an oint node, and its builtin arm re-enters the builtin's emitter with g_poly_builtin_arm set. node_is_oint still counted the program's reader there, so the arm took the emitter's plain sp_int / sp_float for the oint, and the C did not build. bf34b79 wrapped Proc#arity alone. In the call's own builtin arm, node_is_oint now asks for the builtin's answer alone: nullable_int_value leaves the program's methods of the name out. emit_oint_expr then lifts a plain answer and keeps one that holds its own nil (exitstatus). The String pre-arm and the to_i / to_f default arm take the slot's oint the same way. The per-emitter lifts (the Time readers, tv_sec, arity) are gone. Under --int-overflow=promote the reader's ivar is boxed, and poly_dispatch_nullable counted only an Integer or Float ivar, so the dispatch slot was plain and the reader's arm raised TypeError for its nil. A boxed ivar counts as well. test/poly_builtin_reader_beside_nil_reader.rb covers eleven such names on the object (with values and with nils) and on the builtin. Its expected output is CRuby 4.0.7's.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk | ⚪ Minimal · up to
|
A call on a boxed value whose class has a reader that can answer nil, named like a builtin's Integer or Float method,
dispatches over the class and the builtin. The C did not build:
The same happened for
utime,stime,to_i,to_f,ord,lengthandbytesize. bf34b79 fixedarityalone.The call is an oint node, and its builtin arm re-enters the builtin's emitter with
g_poly_builtin_armset.node_is_ointstill counted the program's reader there, so the arm took the emitter's plainsp_int/sp_floatforthe oint.
What changes:
node_is_ointnow asks for the builtin's answer alone.nullable_int_valueleaves out the program's methods of that name (g_nn_builtin_call).emit_oint_exprthen liftsa plain answer, and keeps an answer that holds its own nil (
exitstatus).to_i/to_fdefault arm take the slot's oint the same way.tv_sec,arity) are removed, since the arm now does the lifting.--int-overflow=promote:poly_dispatch_nullablecounted only an Integer or Float ivar, so the dispatch slot was plain, and the reader's armraised TypeError for its nil (
year,hour,length,to_i).test/poly_builtin_reader_beside_nil_reader.rbcovers eleven such names, on the object (with values and with nils) andon the builtin. Its expected output is CRuby 4.0.7's. Without the change, the C does not build under raise or promote.
Verification:
tests are those whose classes have readers or methods named like builtin Integer readers, plus the poly-dispatch /
reader-named / Tms tests.
corpus under wrap (6901 tests) and promote (6932 tests): 0 failures.
promote.
Summary by CodeRabbit
nilacross string, time, process, and callable methods.