Skip to content

parser: move string concatenation out of VisitBinary - #85

Merged
rameel merged 1 commit into
mainfrom
parser/extract-string-concatenation
Nov 24, 2026
Merged

rameel merged 1 commit into
mainfrom
parser/extract-string-concatenation

Conversation

@rameel

@rameel rameel commented Nov 24, 2026

Copy link
Copy Markdown
Owner

VisitBinary handled the string + operator inline in 65 lines: a local Flatten filled two parallel lists of arguments and their types, and value-type operands were boxed by hand.

This PR moves it to ApplyStringConcatenation. GetConcatOperands returns the operands of one expression, and the argument types are filled once, since they are either all string or all object. The explicit boxing is dropped: CreateInjectingArguments already converts value-type arguments to object parameters.

No behavior change: the expression trees, the selected string.Concat overloads, and the error messages are the same for nested concatenations, explicit string.Concat calls, and operands of value, nullable, reference, and interface types.

The string + operator took 65 lines inside VisitBinary, and a local
Flatten filled two parallel lists with four repeated pairs of Add
calls.

Move it to ApplyStringConcatenation. GetConcatOperands returns the
operands of one expression, and the argument types are filled once,
since they are either all string or all object. Value-type operands
are no longer boxed beforehand: CreateInjectingArguments converts them
to the object parameters itself. No behavior change.
@rameel
rameel merged commit 9d361c5 into main Nov 24, 2026
1 check passed
@rameel
rameel deleted the parser/extract-string-concatenation branch November 24, 2026 19:21
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