Repository navigation
Rails-2 r13 (3/3): a class in a join, Module subclass instances, frozen mutators by alias or super, and the rest - #246
Merged
Merged
Conversation
…, frozen mutators reached by alias or super, and the rest - Array#join asks a class its #to_s (minitest's spec names; Arel's 77 MISSING and 124 EXTRA). - An instance of a Module subclass takes the name of the constant it is assigned to, prints by it, and is the owner of its methods. - A Fiber subclass answers Fiber's methods. - defined? with a class as self asks the class's own respond_to_missing?. - Enumerator#first / #take stop at the count when given a block. - A class method named like a builtin keeps its block. - A builtin mutator refuses a frozen String, Array or Hash when an alias or super reaches it; the message names the value's own class. - YAML.load ends the first document before it looks at what follows. Corpus 976, 977, 1050, 1052 to 1056. The loop file has the whole RED table of round 3.
284km
commented
Nov 25, 2026
284km
left a comment
Owner
Author
There was a problem hiding this comment.
Reviewed eb081df. No Critical / Major / Minor findings.
- What changed:
- A Module subclass instance assigned to a constant takes that name (
to_s/inspect/Method#owner). Array#joinasks a Class element its ownto_s.- A Fiber subclass's receiverless
alive?and other Fiber instance methods resolve. defined?in a class consults the class's ownrespond_to_missing?.Enumerator#first/takewith a block stop at the count.- A class method named like a builtin keeps its block.
- Psych ends the first document before reporting what follows.
superfrom an overriding mutator into a builtin String / Array / Hash mutator now raises FrozenError on a frozen receiver, naming the subclass.String#deleteand a no-opArray#deletekeep their non-raising answers.
- A Module subclass instance assigned to a constant takes that name (
- Checks run on the author's build of this branch (tree clean apart from two untracked binaries), against ruby 4.0.10, the evaluator and
MERE_RUBY_VM=1:- All eight new corpus programs (976, 977, 1050, 1052–1056) are identical on all three.
- An extra probe covers frozen subclass instances with overriding
upcase!/delete/replace(String),push/delete(hit and miss) /clear(Array), anddelete(hit and miss) /store/merge!(Hash). It also covers an unfrozenupcase!throughsuper. All are identical to ruby, including the messages. main differed on 11 lines.
- The one difference in that probe is the one you recorded as left:
class MA < Array; def map!(&b) = super; endraises NoMethodError, the same as on main. git merge-treeagainst current main (a6c6aec): clean. No mere-pr-review-watch inline comments.- Local results in the description meet the merge criteria:
- connection_pool 11→0, attribute_methods 7→0, test_fixtures 5→0, yaml_column 2→0;
- base 3→1 (the fork case, now addressed by #237);
- Arel MISSING 77→0 and EXTRA 124→0, with the newly visible BitwiseNot RED listed;
- corpus 885/885 on both modes.
Merging.
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.
Part 3 of 3 of what Rails-2 round 3 found (activerecord, sqlite3). Part 1 is #236 and part 2 #240; this one carries the whole RED table. The remove_const cause (37 RED) and the class-dup cause (8 RED) follow in their own PR.
The checks below ran on the branch based on main 66a7afd. It was rebased onto fdda915 (#243) before the push, with no conflict.
What round 3 measured. activerecord, sqlite3 adapter, 427 files, main 30de57d with #225, against ruby 4.0.10. Round 2 was against 4.0.9: the reference moved between them (#208).
mere-ruby states: 331 COMPLETE, 89 ZERO, 5 INCOMPLETE, 1 COUNT_MISMATCH, 1 MEMORY_LIMIT. No file reached the time limit. Four of the files that did not complete are the same on the reference side (three postgresql files, arel/attributes/attribute_test).
The other three are eager_test (MEMORY_LIMIT) and registration_test and reload_models_test (a forked child crashes in the sqlite3 extension: native).
Time and max RSS of round 3 are not to be compared with later rounds: an append-mode flush rewrote the whole file (#235), and
debug.loghad grown to 45 MB by the end of the round.Round 2's causes are gone: calculations_test 135 RED to 1, batches_test 55 to 1, and nothing is left of the
File.binread,to_ary, index SQL, autoload and migrator groups.RED by cause.
group_bywith keys that define #hash and #eql?alive?with no receiverdoaftercmd [a], xorcmd -> { }, xwent to the last argumentsuperfrom a class's own #dup answered the class itselfdefined?(name)in a class method called the instances' #respond_to_missing?Array#-asked #hash of a small arrayEnumerator#first(n)with a block (batches_test), a class method namedcountlost its block (calculations_test),superinto Hash#delete on a frozen Hash (enum_test), the owner again (statement_cache_test)MISSING. 77 are Arel's: a nested
describegot the name#<Class:0x...>::as(Array#join, below), which is also all 124 EXTRA. 5 are the two forked-child files. 2 are eager_test's last class, which loads a fixture of 65,536 rows.A class in a join is asked its #to_s (77 MISSING, 124 EXTRA)
[cls, "desc"].join("::")asks the class its #to_s, as it asks every other element. minitest's spec classes answer the name they were described with (#to_s and #name come from a module the base class extends), and a nesteddescribebuilds its name with that join.The join wrote the class as
#<Class:0x...>, so 77 of Arel's tests ran under names ruby does not give them. Corpus 976.With the names right, one test that the mismatch hid is RED:
Nodes::UnaryOperation"should handle BitwiseNot" in arel/visitors/to_sql_test. Not looked at yet.An instance of a Module subclass: its name, and the owner of its methods
ActiveRecord keeps each model's attribute methods in a GeneratedAttributeMethods, a Module subclass, set on the model with
const_set.const_store), and it prints by that name:mod_inst_name_s, read byinspect_wand by the dispatch of #inspect / #to_s.Post.ancestors.reject(&:name)is empty.Method#ownerandUnboundMethod#owneranswer the instance, not the nameless Module behind it (mod_inst_self). ActiveRecord'smethod_missingwalksmethod.super_method while !method.owner.is_a?(GeneratedAttributeMethods).With a plain Module as the owner the walk ran off the end, and every attribute read after
undefine_attribute_methodswas a NoMethodError.Corpus 976 and 1052.
A Fiber subclass has Fiber's methods
class ThreadlikeFiber < Fiber; def join; resume while alive?; end; end: the barealive?was a NameError andrespond_to?(:alive?)false. The table of Fiber's methods was asked by the object's own class name. Corpus 977.method_defined?on the subclass is still false.defined?in a class asks the class's own #respond_to_missing?With a class as self,
defined_self_rtmlooked the hook up on the class's instance side.ActiveRecord::TestFixtures defines #respond_to_missing? for the test instances, and its class method
fixturesreadsdefined?(file_fixture_path): the instances' method was called on the class, and itssuperfound nothing. Corpus 1050.Enumerator#first and #take stop at the count with a block too
A block given to them is not called. With one, the call went to the iterator path and ran the enumerator to its end: 12 queries for
enum.first(4) do |batch| ... end. Corpus 1054.en.each_slice(2).first(2)still runs the source to its end.A class method named like a builtin keeps its block
Account.count(:firm_id) { true }is ActiveRecord's owncount.builtin_answersasked the class's instance side, found nothing, and took the call for the builtincount, which drops a block when it has an argument ("given block not used"). A class is asked through its singleton class.Corpus 1055.
A builtin mutator refuses a frozen receiver when an alias or
superreaches itThe frozen check is asked at the doors a call comes through by name, with the name that was called, and it is skipped for a name the class defines itself. So two ways in had no check:
alias_method :regular_writer, :[]=(HashWithIndifferentAccess) wrote to a frozen Hash:Book.statuses["bad_enum"] = 40changed a frozen enum mapping.blt_alias_callrefuses a frozen String, Array or Hash for a mutating source name.superfrom the class's own method.def delete(key) = super(convert_key(key))deleted from a frozen Hash:Book.statuses.delete("published").super_missingrefuses a frozen String, Array or Hash for a mutating name, with the exceptions the direct door has (Array#delete of an element that is not there, a bang method that answers an Enumerator without a block, an arity error first).The message names the value's own class (
frz_cls): "can't modify frozen H2". It was "frozen Hash" for a subclass instance at every door, the builtin names too. Corpus 1053.YAML.load answers the first document before what follows it
libyaml ends a document before it looks for the start of the next one.
The parser raised "did not find expected " before the end of the first document was announced, so
YAML.load('--- {}\n')(single quotes: a backslash and annfollow the mapping) was a SyntaxError where ruby answers{}.lib/psych_parser.rb, regenerated intom_psych_lib.mere.Corpus 1056.
The parser is still more lenient than libyaml elsewhere:
"--- 1\n2: 3"loads as a mapping, where ruby says "mapping values are not allowed in this context".The test files
Each file alone, in round 3's tree, starting from an empty
debug.log:The Arel files have the same counts before and after: what changed is the test names. Compared with ruby's by name, MISSING goes from 50, 13, 5, 4, 3 and 2 to 0 in the six files, and EXTRA from 124 to 0.
One test the wrong names had hidden is RED in to_sql_test (BitwiseNot). base_test's remaining error is the forked child (native).
numericality_validation_test is not in this table: its cause is
superfrom a class's own #dup, in the PR with remove_const.Checked.
run_corpus.sh --both: 885/885.MERE_RUBY_VM=1 run_corpus.sh --both: 885/885.tools/loop_rss_check.sh.mspec/record_hygiene.sh.Left.
remove_constremoved reopens the old class, andsuperfrom a class's own #dup answers the class itself. The PR after this one.Array#-with both sides over 16 elements (from Rails-2 r13 (2/3): a key with its own #hash is one key wherever a table is built #240's review): ruby builds a hash table and asks the receiver's elements for #hash too, so([b] + 20 others) - 20 othersraises when b's #hash does. Here the receiver's elements are not asked. As on main.superinto a block-taking bang method of an Array subclass.class A2 < Array; def map!(&b) = super; endis NoMethodError "undefined method 'map!' for an instance of Array" on main, frozen or not (alsoselect!). Found while writing corpus 1053; not changed here.🤖 Generated with Claude Code