Closed thoj closed 2 years ago
diff --git a/NeoLua/LuaDebug.cs b/NeoLua/LuaDebug.cs
index 9c0ed6a..9249f74 100644
--- a/NeoLua/LuaDebug.cs
+++ b/NeoLua/LuaDebug.cs
@@ -196,7 +196,12 @@ namespace Neo.IronLua
} // func LineProgressExpression
protected override Expression VisitBlock(BlockExpression node)
- => base.VisitBlock(Expression.Block(node.Type, node.Variables, LineProgressExpression(node.Expressions)));
+ {
+ var expr = LineProgressExpression(node.Expressions);
+ if (expr.Count() == 0) return Expression.Empty();
+
+ return base.VisitBlock(Expression.Block(node.Type, node.Variables, expr));
+ }
protected override Expression VisitDebugInfo(DebugInfoExpression node)
=> throw new InvalidOperationException();
This fixes it as far as I can tell. All tests passes but there may be some side effects that I'm not aware of.
Thank you for the fix. I need to clean the master, before I can put this in.
NeoLua Version: master
I am bit out on deep water here. I was trying to debug a Callback function. And the StacktraceDebugger did not emit a stack trace so i switched DebugEngine to LuaExceptionDebugger. I get the exact same error when using LuaTraceLineDebugger. Running my script i got this long error:
After putting some print statements on LuaExceptionVisitor i got the line number where this error happened and i made this minimal example:
Example to reproduce:
If i use LuaStackTraceDebugger.Default. This example runs fine. I'm pretty sure an empty block like this is valid Lua. So i think this is a bug.
If remove the empty block the script runs fine with LuaExceptionDebugger and i actually got the correct line number with the error in my callback :)