Fix nested-lambda variable collision#70
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a codegen correctness issue in ExpressionTreeEmitter where nested lambda parameter locals could collide across sibling lambdas emitted into the same interceptor body, causing CS0128 duplicate-variable compile errors. The change aligns nested-lambda parameter variable naming with the existing per-lambda _varPrefix scheme used elsewhere in the interceptor generator.
Changes:
- Prefix nested-lambda
ParameterExpressionlocal variable names with the per-lambda_varPrefixto ensure uniqueness across sibling lambda emissions. - Add a regression test that compiles the generated interceptor for a
Joinwith sibling key selectors that each contain a nested lambda with the same parameter name. - Update verified snapshot outputs to reflect the new prefixed parameter variable names.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/JoinTests.cs | Adds a regression compilation test covering sibling key-selector lambdas with nested-lambda parameter name collisions. |
| tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/ExecuteUpdateTests.ExecuteUpdateAsync_GeneratesInterceptor.verified.txt | Updates snapshot to reflect prefixed nested-lambda parameter variable names. |
| tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/ExecuteUpdateTests.ExecuteUpdate_SetProperty_WithSwitchExpression.verified.txt | Updates snapshot to reflect prefixed nested-lambda parameter variable names. |
| tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/ExecuteUpdateTests.ExecuteUpdate_SetProperty_WithNullConditional.verified.txt | Updates snapshot to reflect prefixed nested-lambda parameter variable names. |
| tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/ExecuteUpdateTests.ExecuteUpdate_SetProperty_ConstantValue.verified.txt | Updates snapshot to reflect prefixed nested-lambda parameter variable names. |
| src/ExpressiveSharp.Generator/Emitter/ExpressionTreeEmitter.cs | Ensures nested lambda parameter locals include _varPrefix, preventing cross-emitter collisions in shared interceptor bodies. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Resolve variable name collisions in nested lambdas by incorporating a unique prefix for each lambda's parameters. This change prevents compile errors related to duplicate variable declarations in generated interceptors. Additional tests ensure that the generated code compiles correctly under these conditions.