Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/core/Microsoft.Dynamic/Ast/GeneratorRewriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,17 @@ protected override Expression VisitExtension(Expression node) {
return VisitYield(yield);
}

// Lowered async nodes (AsyncExpression / AsyncEnumerableExpression) carry their own generator
// label and are reduced — with their await/yield points rewritten — in their own context so skip here.
// TODO: tracing *into* async bodies will instead require dedicated support here rather than this skip.
if (node is AsyncExpression
#if NET
or AsyncEnumerableExpression
#endif
) {
return node;
}

if (node is FinallyFlowControlExpression ffc) {
return Visit(node.ReduceExtensions());
}
Expand Down
15 changes: 15 additions & 0 deletions src/core/Microsoft.Dynamic/Debugging/DebugInfoRewriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,21 @@ protected override Expression VisitLambda<T>(MSAst.Expression<T> node) {
return node;
}

protected override Expression VisitExtension(Expression node) {
// Lowered async nodes (AsyncExpression / AsyncEnumerableExpression) are opaque boundaries to the
// debug transform, like nested lambdas (see VisitLambda). The async body is sliced into its own
// state machine, against its own generator label, when the node is reduced in its own context.
// TODO: make async bodies traceable via dedicated support here rather than skipping them.
if (node is Microsoft.Scripting.Ast.AsyncExpression
#if NET
or Microsoft.Scripting.Ast.AsyncEnumerableExpression
#endif
) {
return node;
}
return base.VisitExtension(node);
}

// We remove all nested variables declared inside the block.
protected override Expression VisitBlock(MSAst.BlockExpression node) {
if (_transformToGenerator) {
Expand Down
13 changes: 13 additions & 0 deletions src/core/Microsoft.Dynamic/Debugging/LambdaWalker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,18 @@ protected override MSAst.Expression VisitLambda<T>(MSAst.Expression<T> node) {
// Explicitely don't walk nested lambdas. They should already have been transformed
return node;
}

protected override MSAst.Expression VisitExtension(MSAst.Expression node) {
// Explicitely don't walk lowered async nodes (AsyncExpression / AsyncEnumerableExpression).
// Handle them separately (locals belong to their own context).
if (node is Microsoft.Scripting.Ast.AsyncExpression
#if NET
or Microsoft.Scripting.Ast.AsyncEnumerableExpression
#endif
) {
return node;
}
return base.VisitExtension(node);
}
}
}