Repository navigation
fix: keep helpers added after v0.0.23 off Kernel - #67
Merged
Merged
Conversation
SharedControlForwarders is included into Kernel, so every helper added to
it becomes a private method of every object in the process. The 32 names
added since v0.0.23 (table, table_row, stepper, stepper_step, form_row,
list_section, carousel_view, fitted_box, indexed_stack, custom_scroll_view,
sliver_*, draggable_scrollable_sheet, about_dialog and compact spellings)
therefore won over other libraries' method_missing builders: in a Rails app
that loads ruflet_core, Nokogiri::HTML::Builder.new { table { ... } } built
a Ruflet Table and left the document empty.
Move those forwarders to Ruflet::UI::ScopedControlForwarders, included into
the Ruflet and Ruflet::UI singletons only. Builder blocks keep them through
UI::ControlMethods, and a bare call that falls through to Kernel#method_missing
is forwarded to the same Ruflet::DSL helper the Kernel method called, so
stepper(...) in a Ruflet.run block, an app's view or a component builds the
same control as before. Without arguments the call is only taken at a
script's top level or in a Ruflet::App/Ruflet-owned object; elsewhere Ruby
raises as it did at v0.0.23. The top-level object is captured at load
because the embedded mruby VM has no TOPLEVEL_BINDING.
The Kernel surface is pinned to v0.0.23's list in
test/fixtures/kernel_helpers_v0_0_23.txt so later helpers cannot land on
Kernel again.
…rs raising Two regressions from the previous commit on this branch. Ruflet and Ruflet::UI included ScopedControlForwarders after SharedControlForwarders, which put the built-in scoped helpers ahead of it in lookup. Ruflet::Extensions defines a registered helper on SharedControlForwarders, so an extension registered under one of the new names (stepper, table, carousel_view, ...) was shadowed by the built-in on Ruflet.<name> and Ruflet::UI.<name>: 52 of 64 such calls raised ArgumentError. v0.0.23, where those names were not built in, sent all of them to the extension. The include order is swapped so SharedControlForwarders is looked up first. Kernel#method_missing built a control for any call with arguments whatever the receiver, so Object.new.stepper([1]), Struct#table(1), nil.table(1) and app.about_dialog returned controls where v0.0.23 raised NoMethodError. A scoped name now builds only where a private Kernel method could have been called: without an explicit receiver. CRuby reports that through NoMethodError#private_call? on the error super raises; on the embedded VM an explicit call cannot reach the private Kernel#method_missing on its own, so a call is treated as implicit only when Kernel#method_missing is the receiver's own. Explicit calls re-raise the exact NoMethodError v0.0.23 raised. SharedControlForwarders#method_missing declines the scoped names so its generic known_control? path no longer builds them for explicit receivers either. Names an extension has registered keep the generic path, as at v0.0.23. extension_helper_collision_test registers all 32 names as extensions in a child process and checks 11 entry points; it fails on the previous head with 52 wrong calls. kernel_helper_shadowing_test gains explicit- and implicit-receiver cases and a lookup-order check.
…d helpers The comment on ScopedControlForwarders.implicit_call? said a call with an explicit receiver can reach Kernel#method_missing on the embedded VM only through another class's method_missing calling super. mruby's send and public_send also hand an undefined method to method_missing without the visibility check, so record.public_send(:table, rows: []) builds a control there while CRuby raises. Say so. No code change.
…sing
Two changes to which calls of a scoped helper (stepper, table, about_dialog,
...) build a control, so the newer helpers are called the way every helper
v0.0.23 shipped is.
Without arguments. A scoped helper built with no arguments only at the top
level, in a Ruflet::App or on a Ruflet-owned object, and raised NameError
elsewhere: `about_dialog` or `sliver_app_bar` in a component class or a test
failed while `divider` worked. Every v0.0.23 helper is a private Kernel
method and answers a bare word in any object, so a scoped helper now does
too: a call without an explicit receiver builds, with or without arguments.
Explicit calls still raise as at v0.0.23 (`record.table` and
`record.table(1)`), and an object with its own method_missing is still
asked first, so Nokogiri-style builders keep the names.
Ruflet-owned receivers. Kernel#method_missing built for any call on a
Ruflet-owned object, so `Ruflet.text("x").table` and `.about_dialog`
returned controls on CRuby where v0.0.23 and main raise NoMethodError.
v0.0.23 built a generic control there only for a call with arguments, a
block or keywords; that is the rule again. The embedded VM already raised
there.
kernel_helper_shadowing_test checks every scoped name as a bare word,
name() and self.name in a plain object, a component, an app and a test
against Ruflet::DSL.<name>, and zero-argument explicit calls on plain and
Ruflet-owned receivers. extension_helper_collision_test adds a zero-argument
component entry point.
…per-shadowing Conflict in shared_control_forwarders.rb, resolved by meaning rather than by side: #72 added 31 bare helpers to SharedControlForwarders, which is included into Kernel, so each became a method of every object in the process (absorb_pointer, fractionally_sized_box, ignore_pointer, intrinsic_height, intrinsic_width, sliver_padding, clip_oval, clip_rsuperellipse, the five *_transition helpers, form, nested_scroll_view, their compact spellings, and the local_auth/local_authentication service). Keeping main's lines would have failed this branch's v0.0.23 surface test and brought the audit regression back for `form`: Nokogiri::HTML::Builder.new { form(action: "/x") { input(type: "text") } } raised ArgumentError from FormControl instead of building <form>. All 31 move to ScopedControlForwarders and HELPERS, so Kernel keeps exactly the v0.0.23 set and every entry point #72 tests (Ruflet.*, Ruflet::UI.*, Ruflet::DSL.*, WidgetBuilder, DSL.app, builder blocks, bare calls with or without arguments) still builds the same control. #72's tests pass unchanged. Tests: NEW_HELPERS and the extension collision NAMES list all 63 scoped names; the Nokogiri probe also builds a <form>; a test builds every #72 helper bare inside Ruflet.run; explicit-receiver cases cover form, ignore_pointer, fade_transition and local_auth. The Rails test now expects local_auth to be the one scoped name that is not a view helper: views get helpers from the control registry, where the service is local_authentication, as on main.
The decline in SharedControlForwarders#method_missing is reached through Kernel#method_missing's own super, not by a separate path, and the :build branch applies to owned receivers with arguments only on CRuby; the comments now say so. No code change.
… helper
A class whose own method_missing takes no keywords
(def method_missing(name, *args, &block) ... super) hands a call's keywords
on to Kernel#method_missing as a trailing Hash. A scoped helper then took
that Hash as its content: stepper(current_step: 1) in such a class built a
Stepper whose steps were {current_step: 1}, and about_dialog(...) raised
ArgumentError. v0.0.23 raised NoMethodError there; on main the helper was a
Kernel method, found before that method_missing, and got the keywords as
written.
For a call that passed through another method_missing, a trailing Hash of
Symbol keys is read as keywords again, so the helper builds what main
built. Anywhere else arguments are passed as written, and explicit
receivers still raise.
kernel_helper_shadowing_test checks stepper, table, about_dialog,
local_auth and form through such a class against Ruflet::DSL, that an
explicit call on it still raises, and that a positional Hash in an
ordinary object is still positional.
The embedded VM hands method_missing the keywords of send, __send__ and public_send as a trailing Hash, so `send(:table, rows: [])` built a Table whose rows were that Hash and `send(:about_dialog, application_name: "A")` raised ArgumentError, where main's VM built both. On CRuby the same happened on the path for Ruflet-owned receivers (Ruflet::Event, Page, DeviceInfo, a Ruflet::* class of an extension gem) whose method_missing takes no keywords. Kernel#method_missing now decides a scoped helper in one place and builds it through ScopedControlForwarders.build, which reads a trailing non-empty Hash of Symbol keys, when no keywords were passed, as the keywords. That rule is the same on CRuby and the VM and on every path, so dispatch, call_arguments and own_method_missing? are gone. SCRIPT_MAIN is gone too: a top-level call with arguments is already a dsl_receiver? call, and an explicit `main.table` with no arguments now raises NoMethodError as on v0.0.23 and main instead of building. Ruflet::Page no longer answers the 63 scoped names with its "free widget helper" hint (its helper set is v0.0.23's again), so a bare `stepper(current_step: 1)` in a page block builds, `page.stepper = x` sets a page property and `page.respond_to?(:stepper)` is false, as on v0.0.23.
…shes
On the embedded VM, a scoped helper called with a positional splat and
keywords (`stepper(*args, **opts)`, `table(*rows, border_width: 1)`,
`table(...)`) loses the keywords before Kernel#method_missing runs, or
raises a TypeError about whatever was on the stack. That is a heap
over-read in the vendored mruby 449627d: prepare_missing() in src/vm.c
reads a splat call's keyword Hash from argv[ci->n], past the frame,
instead of argv[1]. It already hit v0.0.23 names reached through
method_missing (`elevatedbutton(*a, **k)`); routing the 63 scoped names
there exposes it for them, where main's VM had Kernel methods. Upstream
mruby fixed it in 550d10adb7 (mruby PR #6598), which is not in 449627d.
Nothing in Ruby can restore the keywords, so the fix belongs to the VM
build; build's comment now says so.
tools/embedded_vm_harness/tests/scoped_helper_test.rb checks the scoped
helpers on the VM: no Kernel methods, bare calls, send keywords, explicit
receivers, another builder's method_missing, and forwarding through named
parameters. A pure-Ruby probe tells whether the VM has the mruby bug; the
10 splat-forwarding checks run where it does not and are reported as a
known limit where it does. The file is valid mruby and CRuby.
kernel_helper_shadowing_test now also checks:
- every scoped name forwarded through `*args, **props, &block`, a literal
keyword after a splat, and `...` builds what Ruflet::DSL builds;
- block-only explicit calls on Ruflet-owned receivers (`Ruflet.text("x").table { }`,
`event.stepper { }`, `main.form { }`) still build;
- a Hash with mixed Symbol and String keys stays positional;
- receiverless? treats a receiver Kernel#method cannot inspect as one
whose method_missing is Kernel's.
The receiverless? comment also notes that the VM's explicit-call stop is
mruby 449627d's visibility check, which later mruby drops.
4 tasks
kernel_helper_shadowing_test gains test_ruflet_and_ruflet_ui_build_what_ruflet_dsl_builds. The 63 ScopedControlForwarders methods are now reached only through Ruflet.* and Ruflet::UI.*, and before this only respond_to? and a few names pinned them. The test compares Ruflet.<name> and Ruflet::UI.<name> with Ruflet::DSL.<name> for every scoped name over four shapes: keywords only, an empty positional, a control positional, and a block that adds a child. It adds the keywords a helper needs to build (body: for nested_scroll_view, title: for stepper_step). It also checks that each built patch shows key:, the positional control and the block's child, so a dropped keyword, argument or block changes what is compared. scoped_helper_test.rb now describes the mruby 449627d limit correctly. A splat-forwarded call to a missing method can build without its keywords, build with an earlier call's keywords, or raise. It names the fix, upstream 550d10adb7, which #81 carries as a VM build patch. The probe now runs all three forms the gated checks use: `*a, **k`, `*a` plus a literal keyword, and `...`. It runs them after a call that leaves other keywords behind, and compares positional arguments and keywords exactly. A VM built with the patch runs every check. A new gated check covers the stale case: carouselview forwarded right after a call with key: "earlier" must build with its own key: "k". No lib change.
This was referenced Nov 17, 2026
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.
Problem
The v0.0.23 vs
maincompatibility audit found that every bare helper added since v0.0.23 became a private method of every object in the process.Ruflet::UI::SharedControlForwardersis included intoKernel, so each method added to it lands onKernel.On current
main(742a000) that is 63 names:table,table_row/tablerow,stepper,stepper_step/stepperstep,form_row,list_section,carousel_view,fitted_box,indexed_stack,custom_scroll_view,sliver_app_bar/_grid/_list/_to_box_adapter/_fill_remaining,draggable_scrollable_sheet,about_dialog, plus compact spellings. From feat: add IndexedStack control #29, feat: add list_section control for grouped lists #32, feat: add custom_scroll_view and sliver children #35/feat: add sliver_app_bar #42, feat: add form_row control for labeled form rows #37, feat: add Stepper control #41, feat: add about_dialog control #44, feat: add FittedBox control #46, feat: add Table control #47 and feat: add CarouselView control #51.absorb_pointer,fractionally_sized_box,ignore_pointer,intrinsic_height,intrinsic_width,sliver_padding,clip_oval,clip_rsuperellipse,fade_transition,rotation_transition,scale_transition,size_transition,slide_transition,form,nested_scroll_view, their compact spellings, and thelocal_auth/local_authenticationservice.A Kernel method wins over any other library's
method_missingbuilder with the same name. Afterrequire "ruflet_core":Nokogiri::HTML::Builder.new { table { tr { td "cell" } } }Nokogiri::HTML::Builder.new { form(action: "/x") { input(type: "text") } }<table><tr><td>cell</td></tr></table><form action="/x"><input type="text"></form>nil(a RufletTablewas built instead)ArgumentError: unknown keywords: action(fromFormControl)<table><tr><td>cell</td></tr></table><form action="/x"><input type="text"></form>Why it matters for existing apps
rails_integration.mdloadsruflet_coreinto Rails apps, so upgrading Ruflet changed code that is not Ruflet's: Nokogiri, Builder and Jbuilder-style DSLs, and any object whosemethod_missinghandlestable,form,stepperor the other names.Names that were already Kernel methods at v0.0.23 (
map,option,column,row,image, ...) are left exactly as they were, because v0.0.23 apps call them bare. That set is 406 names, now pinned intest/fixtures/kernel_helpers_v0_0_23.txt.Fix
The 63 forwarders move from
SharedControlForwardersto a new module,Ruflet::UI::ScopedControlForwarders, in the same file.RufletandRuflet::UIsingletons include it, soRuflet.table,Ruflet::UI.stepper,Ruflet.formand the rest still work.SharedControlForwarders, soSharedControlForwardersis looked up first. That is whereRuflet::Extensions.register_controldefines a registered helper, so an extension registered under one of these names still wins (see "Extension contract").WidgetBuilder,DSL::App,Ruflet.column { ... }) already get the names fromUI::ControlMethods.Kernel#method_missinganswers these names first, in one branch. This is how v0.0.23 already reached registry names that had no forwarder, such aselevatedbutton. An object with its ownmethod_missingis asked first and keeps the name, which is what fixes Nokogiri. The branch has three steps, and they are the same on CRuby and on the embedded VM:owned_call?: a call with arguments, keywords or a block on an objectControlFactory.dsl_receiver?accepts builds, with or without a receiver. That object is a script's top level or aRuflet::*object. v0.0.23 built a generic control there for any name.dsl_receiver?is alwaysfalseon the VM, which has noTOPLEVEL_BINDING, as at v0.0.23.receiverless?: any other call asks Ruby, throughsuper, how it was written. It builds only when the call had no explicit receiver, which is exactly when a private Kernel method would have answered it.name(),self.name,send(:name, ...)and__send__.NoMethodErrorthatsuperraised, with v0.0.23's message andprivate_call?false. Examples:record.table(1),record.table,Ruflet.text("x").table.NameError, and any other call form is read fromNoMethodError#private_call?.private_call?. An explicit call never gets this far, because mruby 449627d raises "private method 'table' called" beforeKernel#method_missingruns, as at v0.0.23. So a call that reachesKernel#method_missingon an object whosemethod_missingis Kernel's had no receiver, or wassend/__send__/public_send. One that came through another class'smethod_missingandsuperre-raises. That check usesKernel.instance_method(:method).bind_call, because some classes, such as HTTP requests, define their ownmethod. When even that cannot lookmethod_missingup on the receiver, the call is taken as one that reached Kernel's directly.build: buildsRuflet::DSL.<name>, the method the Kernel helper called, with the same positional meaning (steps,rows,slivers,controls,content). There is one argument rule: when no keywords were passed and the last argument is a non-empty Hash whose keys are all Symbols, that Hash is the keywords.send,__send__andpublic_sendtomethod_missingthis way. So does anymethod_missingwritten without keywords that callssuper, includingRuflet::Page,Ruflet::Event,Ruflet::DeviceInfoand aRuflet::*class of an extension gem.Ruflet::Pageleaves the 63 names toKernel#method_missing. Its "Usex(...)as a free widget helper" hint now covers v0.0.23's helper set again, which is exactlymain's set minus these 63. So a barestepper(current_step: 1)inside a page block builds,page.stepper = xsets a page property, andpage.respond_to?(:stepper)isfalse, all as on v0.0.23. The hint for v0.0.23 helpers such aspage.text("x")is unchanged.SharedControlForwarders#method_missingdeclines these names. Thesupercall in step 2 reaches it, because the module is included intoKernel. Its genericknown_control?branch would otherwise answer an explicit call. Removing the decline makes tests fail; see "Planted bugs".When an extension registers one of these names, the name is a Kernel method again, so this branch stands aside for it. That is the v0.0.23 behaviour.
Changes in this round (7f6a0c3)
This round changes tests, test comments and this description. No line under
lib/changes.packages/ruflet_core/libis byte-identical to 3a7ca07's, and the VM's compiled framework (gem_init.c, sha256825ef63e…) built from this head is the one round 5 built from 3a7ca07 and from ad7a3d5.origin/main(742a000, CI-only since 51bea9b) is merged in.1. Correction: on the embedded VM, a splat-forwarded call can build with another call's keywords
Round 5 said that on this head's VM, a scoped helper forwarded with a positional splat and keywords either drops its keywords or raises. That was incomplete. It can also build, with no error, using the keyword Hash of an earlier, unrelated call. So another call's property values, possibly including handlers, can reach the wire.
The round-5 reviewer's repro, run as
embedded_mruby --preload repro.rb:key: "lit"key: "k"mainkey: "k"key: RAISE NoMethodError(the name does not exist there)key: "k"What such a call gets depends on what earlier calls left on the VM stack. Two small rewrites of this script print
nil(keywords dropped) and raiseTypeErrorinstead.In the forwarding matrix (below), the 258 rows round 5 called "build without their keywords" are two kinds:
key: "lit", the literal keyword of the directRuflet::DSLcall made just before. The call itself passedkey: "k". These are the*a, **k, &bwrapper forcarouselview,customscrollview,draggablescrollablesheet,indexedstack,listsection,slivergrid,sliverlist,sliverpaddingandtablerow.The cause and the fix are in draft #81, which carries upstream mruby 550d10adb7 as a VM build patch. #81 must ship in the same runtime rebuild that first compiles this branch's
ruflet_coreinto the VMs, not later. See "Limits" and "Release coupling".2. New test: the moved forwarders' output is pinned
The 63 forwarders this PR moved into
ScopedControlForwardersare now reached only throughRuflet.*andRuflet::UI.*. Before this round,respond_to?pinned every name but output pinned only a few. The round-5 reviewer planted two bugs that the fullruflet_coreandruflet_railssuites missed:sliverpaddingdropping its keywords;nestedscrollviewdropping its block.test_ruflet_and_ruflet_ui_build_what_ruflet_dsl_buildsnow comparesRuflet.<name>andRuflet::UI.<name>withRuflet::DSL.<name>:[], a control as the positional argument, and a block that adds a child.body:fornested_scroll_view,title:forstepper_step).key:, the positional control and the block's child, so a dropped keyword, argument or block changes what is compared.Plants, one at a time, in each of the 63 forwarder lines: 63 dropping the keywords, 23 dropping the block, 55 dropping the positional argument, and 58 routing to another control's helper with the same parameters. The reviewer's two plants, exactly as written, make 201.
3.
scoped_helper_test.rb(the VM harness test)KNOWN LIMITmessage now say the keywords are dropped, replaced by an earlier call's, or raise. They also name the fix: upstream 550d10adb7, carried by fix: carry mruby's method_missing splat-keyword fix (550d10a) on the pinned VM #81.*a, **k,*aplus a literal keyword, and.... It runs them right after a call that leaves other keywords behind, and compares positional arguments and keywords exactly. On this head's unpatched VM each form gets{}instead of its keywords. On a VM built with fix: carry mruby's method_missing splat-keyword fix (550d10a) on the pinned VM #81, and on CRuby, each gets exactly its own. A VM built from a tree with fix: carry mruby's method_missing splat-keyword fix (550d10a) on the pinned VM #81 therefore runs every check.carouselviewforwarded right after a call withkey: "earlier"must build with its ownkey: "k". With the gate forced open on this head's unpatched VM, it builds withkey: "earlier". All 11 gated checks fail there (3 of 3 runs), so the gated checks do test the fix.scoped_helper_test.rbKNOWN LIMIT(identical over 3 runs)main742a000ArgumentErrorfromFormControl(11 skipped)NoMethodErroratRuflet::DSL.stepper_step, which does not exist there4. Description corrections
main→ this PR" bullet and the first Limits bullet now include the calls that build with another call's keywords.Call matrix, CRuby and embedded VM side by side
The rows below come from two sources:
send/__send__/public_sendand Page setters. That is 17,073 calls, run on ad7a3d5;No executable line under
lib/has changed since ad7a3d5, so round 4's results still describe this head.Representative rows (
kiskey: "k"; generic is v0.0.23's generic control named after the method):stepper(k)/about_dialog/self.about_dialogin an object, component, app or testtable(k)/about_dialog*a, **k,*aplus a literal keyword, or...(def st(*a, **k, &b) = stepper(*a, **k, &b))def st(steps = nil, **k) = stepper(steps, **k)) or**konlyobj.table(k),nil.table(1),app.stepper(k)obj.about_dialog,Ruflet.text("x").about_dialog,TOPLEVEL_BINDING.receiver.about_dialogRuflet.text("x").table(1),.table { },.about_dialog(k),TOPLEVEL_BINDING.receiver.table(k)obj.send(:about_dialog, k),obj.send(:table, k),obj.__send__(:table, k), top-levelsend(:stepper, k)obj.public_send(:table, k)stepper(k)/about_dialogin a class whose ownmethod_missingcallssuper(with or without**kw)obj.stepper(k)on such a classstepper(k)inRuflet::Event/Ruflet::Page/ aRuflet::*class with keywordlessmethod_missingevent.stepper(k),page.stepper(k)page.stepper = 1, thenpage.stepperTagBuilder/Nokogiriform(k),tabletable({ key: "k" }),about_dialog({ key: "k" })(positional Symbol-keyed Hash)Table/ ArgumentErrorTable(key: "k")/ AboutDialogtable({ a: 1 })Tabletable({ "key" => "k" }),table({ rows: [], "border_width" => 1 })rows= that Hashrows= that HashRuflet.column { table(k) },Ruflet.table(k)Every difference, counted
These counts are from round 4's matrices on ad7a3d5, except the forwarding-matrix figures, which are this round's.
VM, v0.0.23 → this PR: 5,007 calls go from raising to building and 1,589 raise differently. 2 build differently:
page.local_authandpage.local_authenticationafter a setter, which are realPagemethods added by #72. No call goes from building to raising. The forwarding matrix agrees: the committed prebuilt VM and a VM built from v0.0.23's Ruby build none of its 1,260 calls.VM,
main→ this PR: building-to-raising, or building differently, happens in three places:method_missing-and-supercontexts listed under "Limits", which raise as on v0.0.23's VM;{ a: 1 }/form_row({ key: "k" })shapes, which raise the same as on CRuby;main's VM builds 660 correctly. This head's VM builds none of those 660 correctly: 234 build without their keywords, 24 build with the keywords of the call made before them, and 402 raise. fix: carry mruby's method_missing splat-keyword fix (550d10a) on the pinned VM #81 removes all of them.sendand__send__with keywords matchmain's VM on every name.CRuby, v0.0.23 → this PR (on the 18,585-call CRuby matrix, which adds
ruby2_keywordsandSimpleDelegatorcontexts):local_auth(key: "k")at the top level gives theLocalAuthenticationservice, andRuflet.column { clip_oval(text("o")) }holds aClipOval.page.local_authandpage.local_authenticationafter a setter, as on the VM.table(1, 2),form(1, 2)table({ a: 1 }):unknown keywords: aabout_dialog(1),local_auth([]),sliver_app_bar(nil, key: "k"),stepper_step({ "key" => "k" })nested_scroll_viewwithoutbody:nested_scroll_view(key: "k"),nested_scroll_view { }form_rowwithout contentform_row(key: "k"),form_row { }stepper_stepwithouttitle:stepper_step(key: "k")Builder blocks (
Ruflet.column { ... }),Ruflet.*andRuflet::DSL.*behave exactly as onmain.public_send, delegators andmethod_missingbuilders behave exactly as on v0.0.23. Every call is identical in theplain.recv,nil.recv,app.recv,kwless.recv,deleg.bare,deleg.recvandtag.barecontexts (693 of 693 each), inpublic_send(126 of 126) and inpage.respond_to?(63 of 63).CRuby,
main→ this PR:public_sendandSimpleDelegator, which now raise as on v0.0.23.{ a: 1 }and now raiseArgumentError.form_row({ key: "k" }), now read as keywords and so "requires content", asform_row(key: "k")already was.local_authwith positional arguments on an explicit Ruflet-owned receiver, such asRuflet.text("x").local_auth(1)or.local_auth(1, 2).mainbuilt a genericLocalAuththere, and v0.0.23 a generic control. They are counted in the v0.0.23 table above.*a-only wrapper calls (def w(*a) = table(*a)called with keywords) now read the trailing Hash as keywords, by the same rule, and so give what the directRuflet::DSLcall gives. 118 go from raising to building and 102 build differently. 4 go from building to raising:form_row/formrowwith onlykey:, which "requires content", asform_row(key: "k")already did.main's VM and this head's VM give the same split.CRuby this PR vs VM this PR: they agree, apart from error message wording, on bare calls in objects without a
method_missingof their own, onsendand__send__, at the top level (including top-levelpublic_send), in builder blocks and onRuflet.*/Ruflet::DSL.*. The exception is calls that splat positional arguments and pass keywords, which lose their keywords on a VM without #81. With #81, all 1,260 forwarding-matrix rows are identical to CRuby's. The VM-only differences are listed below.Limits, stated rather than special-cased
stepper(*args, **opts),table(*rows, border_width: 1)andtable(...).method_missing: on v0.0.23's VM,def eb(*a, **k) = elevatedbutton(*a, **k)raises foreb(content: "x", key: "k"), while the named-parameter form builds. Nothing in Ruby can restore the keywords.ruflet_core. Until then, forward through a named parameter.obj.public_send(:table, ...)builds. mruby handspublic_sendof an undefined name tomethod_missingwith no visibility check and no record of the call form, so it cannot be told fromsend. v0.0.23's VM and CRuby raise. This is raise-to-build only.Kernel#method_missingthrough another class'smethod_missingandsuperraises, whether it was bare or explicit. That covers a user class with its ownmethod_missing, andinstance_evalon aRuflet::Page,Ruflet::EventorRuflet::DeviceInfo. The VM cannot tell a bare call there from an explicit one, so the explicit-receiver rule wins, as on v0.0.23's VM. CRuby builds the bare call. No Ruflet API runs user blocks withinstance_evalon those objects: it does so only onDSL::Appand builders, which have nomethod_missingof their own.dsl_receiver?is alwaysfalsethere. CRuby buildsRuflet.text("x").table(1), as v0.0.23's CRuby built a generic control.Kernel#method_missing. Any mruby update must re-run the VM matrix. Thereceiverless?comment says so. fix: carry mruby's method_missing splat-keyword fix (550d10a) on the pinned VM #81 does not move the mruby pin; it adds only the oneprepare_missinghunk.private_call?is per-thread VM state. CRuby fills it from the thread's last method miss. Amethod_missingthat hits and rescues another miss before callingsupertherefore changes the answer for the call it passes on. In round 3's probe:Clobber.new.table(1)andClobber.new.about_dialogbuild here, where v0.0.23 andmainraised;table(rows: [])in that class raises, as on v0.0.23, wheremainbuilt.Embedded VM: splat-forwarded keywords need #81
Forwarding matrix: 63 names × 5 wrappers × 4 shapes = 1,260 calls.
*a, **k, &b;*awith a literalkey: "lit";...; a named positional parameter with**k;*aonly.(key: "k"),([], key: "k"),(text, key: "k"),(key: "k") { }.Ruflet::DSLcall on the same runtime.Ruflet::DSLcallNoMethodError)main's VM, 742a000main. The 224 others are*a-only wrappers, where a keyword Hash stays positional on a Kernel method.key: "lit"), 402 raise where the direct call builds, and 74 raise a different error where it raises too. The other 504 rows (named parameter,*aonly) are identical to CRuby this head.main*a-only rows)main's VM only.ruflet_coreis compiled into the VM. So this PR's Ruby reaches the embedded VM only when the VM binaries are rebuilt, and a rebuild from a tree with fix: carry mruby's method_missing splat-keyword fix (550d10a) on the pinned VM #81 applies the fix. Shipping this PR's Ruby in a rebuild without fix: carry mruby's method_missing splat-keyword fix (550d10a) on the pinned VM #81 would be the regression above. On CRuby (ruflet run, Rails) there is no such bug, and this PR needs nothing else.def st(steps = nil, **opts, &b) = stepper(steps, **opts, &b). That builds on every runtime.Release coupling
ruby ruby_runtime/vm/patches/mruby_patches.rb --checkexits 0, orgit -C ruby_runtime/third_party/mruby diff --statshowssrc/vm.c).tools/embedded_vm_harness/tests/scoped_helper_test.rbon that VM printsall checks passedwith nothing skipped. AKNOWN LIMITline means the patch is missing.Nothing else here needs a runtime or template release. The template and the prebuilt VM binaries are untouched.
Extension contract
extension_authoring.mdsays a helper registered withRuflet::Extensions.register_controlworks in the bare DSL,Ruflet,Ruflet::UI,Ruflet::DSLand widget builders. Registering a missing Flutter widget under its own name, such as:stepper,:tableor:form, was the natural thing to do before these were built in.extension_helper_collision_testregisters all 63 names in a child process and calls each at 12 entry points:Ruflet.*,Ruflet::UI.*,Ruflet::DSL.*,WidgetBuilder#*;Ruflet.column { name(...) },DSL.app { name(...) };App#view, and a component with and without arguments;Object.new.name(...).Of the 756 calls, 0 miss the extension on v0.0.23, on
mainand on this branch. On 3912c13, the head before the include-order fix, 52 miss. In round 4, the VM extension probe gave output identical to v0.0.23's VM on a VM built from this branch.Tests
packages/ruflet_core/test/kernel_helper_shadowing_test.rb(24 tests) checks:respond_to?(name, true).method_missingbuilder gets every name as a bare word, with arguments and with a block. A realNokogiri::HTML::Builderbuilds<table>and<form action="/x">.public_send;Ruflet.text("x")and the top-level object;TOPLEVEL_BINDING.receiver, a page and an event.name()andself.name, in a plain object, a component, an app and a test, gives whatRuflet::DSL.<name>gives.test_ruflet_and_ruflet_ui_build_what_ruflet_dsl_builds. Every name throughRuflet.*andRuflet::UI.*, over 4 shapes, builds whatRuflet::DSLbuilds, and each built patch shows the keyword, the positional control and the block's child.test_forwarded_calls_build_what_the_direct_call_builds. Every name, forwarded through*args, **props, &block, a literal keyword after a splat, and..., with 4 argument shapes, builds whatRuflet::DSLbuilds.test_keywords_that_arrive_as_a_trailing_hash_are_keywords. Seven calls run in a keywordless user class, aRuflet::*-named keywordless class,Ruflet::EventandRuflet::Page, and assend,__send__andTOPLEVEL_BINDING.receiver.sendwith the keywords written as a trailing Hash. Each must equalRuflet::DSL's patch with real keywords.test_other_trailing_hashes_are_passed_as_written. A String-keyed Hash, a mixed-key Hash, an empty Hash and a Hash beside keywords stay positional.test_without_private_call_a_call_that_reaches_kernel_directly_had_no_receiver. This runsreceiverless?on CRuby with a VM-like error that has noprivate_call?. It covers an object with its ownmethod, a class with its ownmethod_missing(with and without its ownmethod), another name, a bare-wordNameError, an unrelated constantNameError, and a receiverKernel#methodcannot lookmethod_missingup on.test_an_unrelated_name_error_behind_kernel_propagates. In a child process, a module included intoKernelafter Ruflet raises aNameErrorfor another name. That error propagates instead of being taken for the helper's miss.test_page_leaves_the_new_helpers_to_kernel. It checks the barestepper(current_step: 1)andabout_dialogin a page block,page.table(rows: []),page.about_dialograising,respond_to?, the setter, and the unchangedpage.text("x")hint.Ruflet.run, apps and components, and the builder entry points, as before.tools/embedded_vm_harness/tests/scoped_helper_test.rbis the same contract on the VM: no Kernel methods, bare calls,send/__send__keywords, explicit receivers, another builder'smethod_missing, forwarding through named parameters, and 11 splat-forwarding checks gated on the probe described in "Changes in this round". Results are in the table there. The file is valid mruby and CRuby.packages/ruflet_core/test/extension_helper_collision_test.rbcovers all 63 names at 12 entry points, as described above.packages/ruflet_rails/test/html_dsl_helpers_test.rbchecks:local_authis an ActionView helper, and none is a Kernel method;local_authis only the Ruby DSL's short name for thelocal_authenticationservice, and views get helpers from the control registry;How the tests were checked:
Planted bugs, this round: 201 forwarder plants, all caught by the new test; see "Changes in this round".
Planted bugs, earlier rounds (from round 5, on 3a7ca07): 22 implementer plants and 18 reviewer plants in
lib/, each caught by at least one of the PR's test files. There were also 6 VM-path plants overlaid on the compiled framework, each failingscoped_helper_test.rbon the unpatched and the patched VM. Among them:owned_call?: ignoring the block, keywords or positional arguments; never, always;build:keys.any?, dropping keywords or the block, no keyword restoration, the Symbol-key or non-empty check dropped, the last Hash taken despite keywords;receiverless?andkernel_method_missing?: the name check dropped, always true,private_call?ignored, the VM fallback usingreceiver.methodor rescuing tofalse;NameErrorhandling: rescuing onlyNoMethodError, never re-raising, theNameErrorbranch dropped;RufletorRuflet::UI, the include order swapped,HELPERSmissing names, a forwarder removed;formorstepperback on Kernel, a keywordlessKernel#method_missing, the generic build path;SharedControlForwardersdecline, the Page exclusion,helper?ignoring extensions.This round removes no check or assertion and changes no
lib/line, so those plants are still caught. Thescoped_helper_test.rbprobe changed, so the gated checks were re-checked with the gate forced open on the unpatched VM (all 11 fail).Copied onto other trees (this round's test files, CRuby 4.0.5):
main742a000, 13 fail (6 failures, 7 errors), as in round 5. The new test passes there:mainhas the same 63 forwarder lines, onSharedControlForwarders.Ruby 3.2.9: the shadowing test gives 24 runs, 0 failures, 1 skip (Nokogiri is not installed for that Ruby). The collision test and
scoped_helper_test.rb(87 checks) pass.Random seeds: the shadowing test passes on 10 random seeds.
Suites
On head
7f6a0c37, every file run in its own process with Homebrew Ruby 4.0.5:ruflet_core: 189/189 files.ruflet_server: 13/13.ruflet: 13/13, with no rerun needed.ruflet_rails: 17/17, run with-Ito the sibling packages.Gemfile.lockis untouched.ruflet_record: 5/5 (not touched by this PR; run for completeness).That is 1,608 runs (1,584 without
ruflet_record), 0 failures and 1 skip (the gateddsl_presented_controlstest). The shadowing test ran its Nokogiri test (0 skips), and the worktree was clean afterwards.ruby -won the shadowing test shows only the existingpage.rbCGI warning.H1 goldens: the harness (
packages/ruflet/test/compat/compat.rb) is not onmainyet. Overlaid from the currentorigin/test/cli-compat-goldens(c6085a7, #73) withgit merge-treeonto this head,ruby test/compat/compat.rbchecked 234 goldens with 0 differences.Other open PRs: this head merges with each of #71, #81, #82, #83, #84, #86, #87, #88, #89 and #90 with no conflict (
git merge-tree). On each merged tree except #81, these all pass:ruflet_core,ruflet_rails,ruflet_serverandruflet;html_dsl_helperstests;scoped_helper_test.rbon CRuby.#81 changes only VM build files. The "this head + #81" VM above is built from that merge.
Embedded mruby VM: verified on current sources
These are scratch macOS arm64 builds made this round with the vendored mruby 449627d, the same steps as
tools/build_apple_vm_artifacts.sh(arm64 slice only: this Mac has no Rosetta) andtools/embedded_vm_harness/build.sh. The probes ran underembedded_mruby --preload:gem_init.csha256825ef63e…, identical to round 5's head build and to the round-5 reviewer's;git merge-treeof this head and fix: carry mruby's method_missing splat-keyword fix (550d10a) on the pinned VM #81's head fe1bd60. The build config's hook applied fix: carry mruby's method_missing splat-keyword fix (550d10a) on the pinned VM #81's patch (ruflet: applied mruby patch 0001-Fixed-heap-buffer-overflow-in-method_missing.patch), and the framework is the same825ef63e…;main, 742a000: framework5c265927…, identical to round 5'smainbuild;main's build config with v0.0.23'sruflet_coreandruflet_server(232 lib files, identical to the tag). It reportsRuflet::VERSION0.0.23;ruby_runtime/macos/Frameworks/libruflet_vm.a, which reports 0.0.21, astools/embedded_vm_harness/build.shdoes by default.Results:
scoped_helper_test.rb, as above;compat_test.rb,regexp_test.rb,icon_deferral_test.rb,ruflet_gem_test.rb,ruflet_record_gem_test.rb: byte-identical output on this head's VM, the fix: carry mruby's method_missing splat-keyword fix (550d10a) on the pinned VM #81 VM andmain's VM.icon_deferral_test.rbpasses.compat_test.rb:67(SystemExitis undefined),regexp_test.rb:132(anOnigRegexpconversion), and lines 7 and 8 of the two gem tests (stale version pins, which Release readiness: fix stale VM version checks and lockfiles #83 addresses).From round 4, on a VM built from ad7a3d5 (same executable code as this head):
main's VM;Doc-harness result
From round 5, on 3a7ca07, which has the same
lib/as this head. The harness lived in a scratchpad that has since been cleared and was not re-run this round. All 183 documented examples were run withcompat/harness/run.rband compared with the v0.0.23 baseline, ignoringtree_probe:control_dropdown__3,control_floating_action_button__2,control_switch__2,rails_api_reference__3,rails_assets__3,rails_integration__5,rails_native_html__1andrails_native_html__2.Cost
Measured in round 4 on ad7a3d5, which has the same executable code as this head. CRuby 4.0.5, 20,000 calls, process CPU time, best of 7 rounds, each tree run twice. The machine's load average was above 400 throughout, so treat these as rough. Times are in µs per call.
mainecc394a7text("x")(a v0.0.23 Kernel helper)Ruflet.table_row([])table_row([])in a componentstepper(current_step: 1)ignore_pointerstepper(current_step: 1)through a keywordlessmethod_missingA bare call to a scoped name costs about 4 to 8 µs more than on
main. That is onemethod_missingdispatch plus theNameErrorthatsuperraises and that is rescued. Calls to the 406 v0.0.23 helpers and toRuflet.*do not go through this path.Not in scope
Ruflet::Extensions.register_controlstill go onto Kernel, as at v0.0.23. That includes one registered under a scoped name.extensions.rbis identical): on the embedded VM,register_controlraisesTypeError: wrong argument type String (expected Symbol).define_control_helpercallsKernel.send(:private, <String>).ruby_runtimeare not rebuilt here, matching how feature PRs are merged.table: the ERBtablehelper still emits<table>, which maps toDataTable. This is an audit side note.page.local_auth/page.local_authentication: these are realPagemethods added by New controls and their protocol, client actions, local auth, and review follow-ups #72 and are unchanged.