You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
debug.traceback failed on anonymous function #1665
When anonymous functions are included in TS code, stack.traceback printing doesn't work exactly as expected, such as in the form SOME_PATH\dist\main.ts:43: in function <SOME_PATH\dist\main.lua:65>.
This is because the "<" escapes as a non-whitespace character matching the %S, causing it to be considered part of the path.
On Windows, you can quickly fix this by changing the pattern to ([^%s<]+)%.lua:(%d+).
This isn't the most elegant fix, considering that "<" can be part of a filename on Unix-like systems.
Additional, my guess is that if there are spaces in the entire path, it may also cause unexpected behavior because of %S.
However, collecting the paths to build a regular expression can be quite risky.
Do you have any suggestions?
Hi @Perryvw, I've added a regression test for this in PR #1666.
If you'd like a quick way to reproduce the issue, nested IIFEs work well — the anonymous function definitions show up as <file.lua:N> in debug.traceback(), and those lines do have sourcemap entries:
Activity
fix `debug.traceback` failing on anonymous function (TypeScriptToLua#…
Perryvw commentedon Nov 2, 2025
Which Lua runtime are you using? In my quick check I don't see the
<>notation used in Lua 5.3 or 5.4.And do you have some example code that actually produces the problem? I've been using this to test:
test: add regression test for anonymous function traceback mapping (T…
ChouUn commentedon Feb 27, 2026
Hi @Perryvw, I've added a regression test for this in PR #1666.
If you'd like a quick way to reproduce the issue, nested IIFEs work well — the anonymous function definitions show up as
<file.lua:N>indebug.traceback(), and those lines do have sourcemap entries:Hope that helps!
test: address review feedback for anonymous function traceback test (T…
fix `debug.traceback` failing on anonymous function (#1665) (#1666)