Repository navigation
Implement top-level private/public/protected - #428
Merged
Merged
Conversation
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>
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.
At the top level,
selfismain(a plainObject), which had noprivate/public/protectedmethods, soprivate :foo— or a bareprivate— raisedNoMethodError(undefined method 'private' for Object). Any spec file whose fixtures use them at the top level (forexample
core/main/fixtures/classes.rbdoingpublic :m/private :m) failed to load entirely, taking all of that file's exampleswith it.
main's singleton class now getsprivate/public/protected,delegating to
Object(the top-level default definee): with namearguments they set the visibility of the named
Objectinstance methods(returning the argument or array, as MRI does), and the bare form sets
the default visibility of subsequent top-level
defs. This reuses thesame
setVislogic theModulemethods use, targetingObject.Verified against ruby 4.0.6. This unblocks seven previously unloadable
spec files (
core/main/{define_method,include,private,public, ruby2_keywords,using}andlanguage/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