Track nested-lambda closure captures during flat-expression construction#546
Track nested-lambda closure captures during flat-expression construction#546
Conversation
Agent-Logs-Url: https://github.com/dadhi/FastExpressionCompiler/sessions/534dad56-d0d5-41e9-ae8c-bef331240b75 Co-authored-by: dadhi <39516+dadhi@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dadhi/FastExpressionCompiler/sessions/534dad56-d0d5-41e9-ae8c-bef331240b75 Co-authored-by: dadhi <39516+dadhi@users.noreply.github.com>
| /// <summary>Maps a lambda node to a captured outer parameter/variable identity used for closure creation.</summary> | ||
| public struct LambdaClosureParameterUsage | ||
| { | ||
| public int LambdaIndex; |
There was a problem hiding this comment.
The possible range of indexes is 2 bytes. Please use it here for indexes as well. Use explicit zyruct kayout to avoid padding.
Add xml doc comments for the public fields. The ci is failing.
Use the consistent naming for indexes - if we are using Idx in FE nodes, use Idx here indtead of index.
| if (children.Count == 0) | ||
| return; | ||
|
|
||
| SmallList<int, Stack8<int>, NoArrayPool<int>> lambdaParameterIds = default; |
There was a problem hiding this comment.
Use shorts or better ushort for all stacks/lists with indexes here and below. Why are we wating 2 bytes per index?
| @@ -197,6 +213,12 @@ public struct ExprTree | |||
| /// enabling callers to locate all try regions without a full tree traversal.</summary> | |||
| public SmallList<int, Stack16<int>, NoArrayPool<int>> TryCatchNodes; | |||
There was a problem hiding this comment.
Ushort instead of int for each index operating list.
Agent-Logs-Url: https://github.com/dadhi/FastExpressionCompiler/sessions/c6cac0b3-185b-4595-91a8-f2d3176e31e5 Co-authored-by: dadhi <39516+dadhi@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dadhi/FastExpressionCompiler/sessions/c6cac0b3-185b-4595-91a8-f2d3176e31e5 Co-authored-by: dadhi <39516+dadhi@users.noreply.github.com>
|
@copilot please fix this warning from ci: Warning: D:\a\FastExpressionCompiler\FastExpressionCompiler\test\FastExpressionCompiler.IssueTests\Issue500_IndexOutOfRangeException_with_value_objects_implicit_conversions.cs(27,85): warning CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. [D:\a\FastExpressionCompiler\FastExpressionCompiler\test\FastExpressionCompiler.IssueTests\FastExpressionCompiler.IssueTests.csproj::TargetFramework=net8.0] |
Agent-Logs-Url: https://github.com/dadhi/FastExpressionCompiler/sessions/ca45f74d-d8c3-439d-ba63-e44066b21a13 Co-authored-by: dadhi <39516+dadhi@users.noreply.github.com>
Fixed in c388121 by enabling nullable context in the shared Issue500 test file so the |
FlatExpression was indexing lambda/block/control-flow nodes, but it was not carrying forward the closure-shaping information that
TryCollectInfoderives for nested lambdas. This change makes flat-expression construction record captured outer parameters/variables directly, so nested-lambda closure metadata is available without a separate collect pass.Add closure-capture metadata to
ExprTreeLambdaClosureParameterUsageandExprTree.LambdaClosureParameterUsagesCollect captures during flat construction
ExprTree.Lambda(...)APIExprTree.FromExpression(...)Preserve identity-based mapping
ExprNode.ChildIdx) so closure analysis stays aligned with the existing flat-tree identity modelAdd focused coverage
ToFlatExpression()conversion fromSystem.Linq.ExpressionsExample: