Allow less strict attribute argument parsing - #1793
Open
nevans wants to merge 1 commit into
Open
Conversation
The prism parser is strict about attribute arguments: it only parses as
an attribute when _all_ arguments are symbols. rdoc 7.2's parser simply
ignored any arguments after the initial symbol arguments.
As an example, the rdoc for `Net::IMAP::Config` intentionally took
advantage of the looser parsing done by rdoc 7.2. That class redefines
`attr_reader`, `attr_writer` and `attr_accessor` to add keyword
arguments for type validation/coercion and defaults:
```ruby
# Seconds to wait until a connection is opened.
#
# Applied separately for establishing TCP connection and starting a TLS
# connection.
#
# If the IMAP object cannot open a connection within this time,
# it raises a Net::OpenTimeout exception.
#
# See Net::IMAP.new and Net::IMAP#starttls.
#
# The default value is +30+ seconds.
attr_accessor :open_timeout, type: Integer, default: 30
```
rdoc 7.2 simply ignored the unknown keyword args, and parses this no
differently from `attr_accessor :open_timeout.`
Fixes ruby#1790.
nevans
requested a deployment
to
fork-preview-protection
August 28, 2026 14:29 — with
GitHub Actions
Waiting
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.
The prism parser is strict about attribute arguments: it only parses as an attribute when all arguments are symbols. rdoc 7.2's parser simply ignored any arguments after the initial symbol arguments.
As an example, the rdoc for
Net::IMAP::Configintentionally took advantage of the looser parsing done by rdoc 7.2. That class redefinesattr_reader,attr_writerandattr_accessorto add keyword arguments for type validation/coercion and defaults:rdoc 7.2 simply ignored the unknown keyword args, and parses this no differently from
attr_accessor :open_timeout.Fixes #1790.