Skip to content

Document why core signatures leave out methods defined only under -n/-p - #3219

Open
zonuexe wants to merge 1 commit into
ruby:masterfrom
zonuexe:docs-interpreter-option-methods
Open

zonuexe wants to merge 1 commit into
ruby:masterfrom
zonuexe:docs-interpreter-option-methods

Conversation

@zonuexe

@zonuexe zonuexe commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Ruby defines the module functions Kernel?.sub, Kernel?.gsub, Kernel?.chop and Kernel?.chomp only when it runs with -n or -p (ruby.c). An ordinary script doesn't have them:

$ ruby -e 'p respond_to?(:gsub, true)'
false
$ echo x | ruby -ne 'p respond_to?(:gsub, true)'
true

core/kernel.rbs already leaves these methods out, but no document says so. If you compare the C source with RBS, they show up as missing signatures.

This PR adds a Q&A entry to docs/CONTRIBUTING.md. It explains that RBS doesn't declare them because a declaration would let type checkers accept calls that raise NoMethodError.

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