parser: remove first_param
from parse_param_general
#144198
Closed
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.
Motivation
Currently,
parse_param_general
handles both the general function parameters and the optional parsing of theself
receiver as the first parameter.This mixes two distinct responsibilities:
self
receiver (which has unique grammar and semantics),This makes the function harder to understand and harder to test.
What This PR Does
self
parameter out ofparse_param_general
.parse_fn_params
before entering the general parameters loop.first_param
boolean and its branching logic.req_name
as-is (required name enforcement still makes sense).Behavior After Refactor
Behavior is functionally identical. The only change is structural:
Tests
self
receiver handling remain correct.Benefits
self
parsing is specialized and now handled separately.self
.Also parsing the self parameter can be extracted into a small inline function to isolate its logic from regular parameter parsing.
Reviewer Notes
self
parsing should be refactored further.