Skip to content

Implement top-level private/public/protected - #428

Merged
tannevaled merged 1 commit into
mainfrom
feat/cluster6
Aug 21, 2026
Merged

tannevaled merged 1 commit into
mainfrom
feat/cluster6

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

At the top level, self is main (a plain Object), which had no
private/public/protected methods, so private :foo — or a bare
private — raised NoMethodError (undefined method 'private' for Object). Any spec file whose fixtures use them at the top level (for
example core/main/fixtures/classes.rb doing public :m / private :m) failed to load entirely, taking all of that file's examples
with it.

main's singleton class now gets private/public/protected,
delegating to Object (the top-level default definee): with name
arguments they set the visibility of the named Object instance methods
(returning the argument or array, as MRI does), and the bare form sets
the default visibility of subsequent top-level defs. This reuses the
same setVis logic the Module methods use, targeting Object.

Verified against ruby 4.0.6. This unblocks seven previously unloadable
spec files (core/main/{define_method,include,private,public, ruby2_keywords,using} and language/def_spec) so their examples run —
a full language+core sweep shows +39 with no regressions, and the
whole-suite coverage gate stays at 100.0%.

🤖 Generated with Claude Code

At the top level, self is `main` (a plain Object), which had no
private/public/protected methods, so `private :foo` / a bare `private`
raised NoMethodError ("undefined method 'private' for Object"). Any
spec file whose fixtures use them at the top level — e.g.
core/main/fixtures/classes.rb doing `public :m` / `private :m` — failed
to load entirely, taking the whole file's examples with it.

main's singleton class now gets private/public/protected, delegating to
Object (the top-level default definee): with name arguments they set the
visibility of the named Object instance methods (returning the argument
or array, as MRI does), and the bare form sets the default visibility of
subsequent top-level defs. This reuses the same setVis logic the Module
methods use, targeting Object.

Verified against ruby 4.0.6; this unblocks the six previously unloadable
core/main spec files (define_method, include, private, public,
ruby2_keywords, using) so their examples run.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 988ef10 into main Aug 21, 2026
7 checks passed
@tannevaled
tannevaled deleted the feat/cluster6 branch August 21, 2026 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant