fix debug.traceback failing on anonymous function (#1665)#1666
fix debug.traceback failing on anonymous function (#1665)#1666ChouUn wants to merge 1 commit intoTypeScriptToLua:masterfrom
debug.traceback failing on anonymous function (#1665)#1666Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug in the source map traceback regex pattern to avoid incorrectly matching anonymous function stack entries. The regex is updated to exclude the < character from file path matching, preventing matches against patterns like in function <...> that appear in Lua stack traces.
- Updated regex pattern from
(%S+)to([^%s<]+)to exclude<character - Added comprehensive comments explaining the fix and its limitations
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1665 | ||
| // Avoid matching anonymous function stack entries like `in function <...>` | ||
| // by excluding `<` before the file path. | ||
| // TODO: This will still fail for paths containing spaces. |
There was a problem hiding this comment.
[nitpick] The TODO comment mentions that paths with spaces will fail, but this is a known limitation of the current implementation. Consider adding more context about why this limitation exists (the pattern uses [^%s<]+ which excludes whitespace) and potential workarounds or future solutions.
| // TODO: This will still fail for paths containing spaces. | |
| // TODO: This will still fail for paths containing spaces. | |
| // The Lua pattern used here ("([^%s<]+)%.lua:(%d+)") excludes whitespace to avoid matching | |
| // anonymous function stack entries (e.g., 'in function <...>'). As a result, file paths with spaces | |
| // are not matched and will not be rewritten in the stack trace. | |
| // Potential workarounds: use a more sophisticated pattern, escape spaces in file paths, or | |
| // post-process stack traces to handle these cases in the future. |
more details in #1665