Use lazy fields accessor for empty header operations - #1672
Open
OskarEichler wants to merge 1 commit into
Open
OskarEichler wants to merge 1 commit into
OskarEichler wants to merge 1 commit into
Conversation
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.
Summary
Use the existing fields accessor when copying a header or collecting its errors. A newly constructed empty header has no @fields yet, so dup/clone/errors currently call methods on nil.
Reproduction
Run in a fresh process against the gem:
Verification
bundle exec rake spec: 1,837 examples, zero failures, four existing pending, both before and after this isolated patch, on Ruby 4.0.6 via rbenv.git diff --checkpass. Supplementary Lint output retains the same 275 existing findings by file/cop/message.Limitations and contribution policy
CONTRIBUTING.md and relevant existing specs were reviewed; a changelog entry is included. The requesting project's explicit no-new-tests policy prevents adding or modifying repository specs, so this PR supplies an inline reproduction and runs the existing suite plus external checks. This differs from upstream's request for a regression spec and may need maintainer follow-up. No claim of coverage completeness, other Ruby engines/versions, production throughput, or live delivery. Verification uses an external bundle with the consumer's patched network/mini_mime dependencies; benchmark is supplied externally for Ruby 4 (existing #1655/#1666), without changing the gem dependencies or CI.
Breaking changes
No intended breaking changes. Empty-header operations now succeed; the general shallow-freeze contract is unchanged.