Require exactly one name for a requires or optional block - #2991
Merged
Merged
Conversation
ericproulx
force-pushed
the
fix/group-block-needs-one-name
branch
2 times, most recently
from
September 22, 2026 22:39
4946e74 to
eae5bab
Compare
Danger ReportNo issues found. |
dblock
approved these changes
Sep 23, 2026
A `requires` or `optional` given a block declared something other than it read when it did not name exactly one parameter: - With no name, the block's params were declared one level up, and under `optional` they were still required. - With several names, all of them were required, but only the first got the block's params, and the others were left out of `declared`. `DSL::Parameters#declare` now raises ArgumentError for either. That makes `ParamsScope#new_scope`'s `if element` guard around the group-type check unreachable, so the check always runs, and the `type || Array` fallback behind it goes too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ericproulx
force-pushed
the
fix/group-block-needs-one-name
branch
from
September 23, 2026 15:04
eae5bab to
6a34566
Compare
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.
A
requiresoroptionalgiven a block silently declares something other than what it reads unless it names exactly one parameter.No name. The block's params are declared one level up, and under
optionalthey are still required:Several names. Every name is required, but only the first gets the block's params, and the rest are left out of
declared:DSL::Parameters#declarenow raisesArgumentError("a params block needs exactly one parameter name, gotn") for either form.ParamsScope#new_scopeguarded its group-type check withif element, which could only be false for a block with no name. The branch was never covered, and it is how this came up. With the name now enforced, the check always runs, and thetype || Arrayfallback after it is gone.UPGRADING explains how to rewrite either form. Specs cover both forms for
requiresandoptional; all four fail on master.🤖 Generated with Claude Code