diff --git a/Src/Microsoft.Dynamic/Debugging/DebugInfoRewriter.cs b/Src/Microsoft.Dynamic/Debugging/DebugInfoRewriter.cs index 17496e1d..838465e3 100644 --- a/Src/Microsoft.Dynamic/Debugging/DebugInfoRewriter.cs +++ b/Src/Microsoft.Dynamic/Debugging/DebugInfoRewriter.cs @@ -17,7 +17,7 @@ namespace Microsoft.Scripting.Debugging { using Ast = MSAst.Expression; using System.Threading; - + /// /// Used to rewrite expressions containing DebugInfoExpressions. /// @@ -355,12 +355,17 @@ protected override MSAst.Expression VisitDebugInfo(MSAst.DebugInfoExpression nod // Update the location cookie int locationCookie = _locationCookie++; if (!_transformToGenerator) { - var tracebackCall = Ast.Call( - typeof(RuntimeOps).GetMethod(nameof(RuntimeOps.OnTraceEvent)), - _thread, - AstUtils.Constant(locationCookie), - Ast.Convert(Ast.Constant(null), typeof(Exception)) - ); + MSAst.Expression tracebackCall = null; + if (locationCookie == 0) { + tracebackCall = Ast.Empty(); + } else { + tracebackCall = Ast.Call( + typeof(RuntimeOps).GetMethod(nameof(RuntimeOps.OnTraceEvent)), + _thread, + AstUtils.Constant(locationCookie), + Ast.Convert(Ast.Constant(null), typeof(Exception)) + ); + } transformedExpression = Ast.Block( Ast.Assign(