You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Lazily loaded libraries fire user method_added/inherited hooks #139
Libraries IronRuby loads lazily run their definitions in the middle of user code: ErrorHighlight, DidYouMean and prism's Ruby half (loaded when the first error message is built), StringIO and others. A program's Module#method_added / singleton_method_added / inherited hooks then fire for thousands of library methods and classes. CRuby loads error_highlight and did_you_mean at boot, before any user code.
classModule;defmethod_added(n)=($n =($n || 0) + 1);endbegin;nosuch;rescueNameError=>e;e.message;endp $n # CRuby: 1 IronRuby: 3005 (3234 after a detailed_message)
Seen in Experiments/Methods/Visibility/s.rb: 3,400 hook calls. Possible fixes: suppress user hooks while an internal library loads, or load these where user hooks can't be installed yet.
Found by running the scripts PR #119 deleted (Tests/Experiments, Tests/Legacy) on CRuby 4.0.9 and on IronRuby built from master c7f70cf (net10.0, Linux).
error_highlight in CRuby 4.0 requires prism's Ruby half lazily when it first spots an error, so a program's method_added, const_added and inherited see thousands of prism definitions there too. The repro in this issue went through another path at the time.
The remaining ~4% (3,131 vs 3,004) comes from StringIO and io/console, which are C in CRuby and Ruby in IronRuby. That is not worth hiding hooks for: muting them would make IronRuby less like CRuby for prism, which is the bulk.
Activity
Largo commentedon Nov 8, 2026
Closing: the premise was wrong. CRuby 4.0.9 fires the same hooks.
error_highlight in CRuby 4.0 requires prism's Ruby half lazily when it first spots an error, so a program's
method_added,const_addedandinheritedsee thousands of prism definitions there too. The repro in this issue went through another path at the time.The remaining ~4% (3,131 vs 3,004) comes from StringIO and io/console, which are C in CRuby and Ruby in IronRuby. That is not worth hiding hooks for: muting them would make IronRuby less like CRuby for prism, which is the bulk.