Skip to content

Preserve ancestor visibility when creating module functions - #1828

Draft
st0012 wants to merge 2 commits into
ruby:masterfrom
st0012:codex/module-function-visibility
Draft

st0012 wants to merge 2 commits into
ruby:masterfrom
st0012:codex/module-function-visibility

Conversation

@st0012

@st0012 st0012 commented Sep 20, 2026

Copy link
Copy Markdown
Member

Found when reviewing #1825: Calling module_function :foo can incorrectly change the visibility of all foo methods in the module's inheritance chain. For module_function's handling, the visibility change shouldn't go through ancestors.

@st0012 st0012 added the bug label Sep 20, 2026
@github-actions

github-actions Bot commented Sep 20, 2026

Copy link
Copy Markdown

Documentation preview

View the preview

Commit: ec2e620

@st0012
st0012 marked this pull request as ready for review September 20, 2026 21:29
Copilot AI balanced review requested due to automatic review settings September 20, 2026 21:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The new inherited-method path can emit a spurious duplicate-method warning.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Preserves ancestor method visibility when creating module functions.

Changes:

  • Uses scoped visibility handling for module functions.
  • Adds inherited and overridden method regression tests.
File Description
test/​rdoc/​parser/​ruby_test.rb Tests ancestor visibility preservation.
lib/​rdoc/​parser/​ruby.rb Changes module-function visibility handling.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/rdoc/parser/ruby.rb Outdated
Copilot AI review requested due to automatic review settings September 21, 2026 23:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Writer-only attributes can incorrectly shadow reader methods from farther ancestors.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (1)

Comment thread lib/rdoc/parser/ruby.rb
Comment on lines +565 to +566
matches = (methods_by_name[method.name] ||= [])
next unless matches.empty? || matches.first.parent == method.parent
@st0012
st0012 marked this pull request as draft September 21, 2026 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants