Skip to content

Commit 4bc32b7

Browse files
committed
fix debug.traceback failing on anonymous function (#1665)
1 parent 1ed3b4d commit 4bc32b7

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/lualib/SourceMapTraceBack.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ export function __TS__SourceMapTraceBack(this: void, fileName: string, sourceMap
4949
return `${file}:${line}`;
5050
};
5151

52-
let [result] = string.gsub(trace, "(%S+)%.lua:(%d+)", (file, line) =>
52+
// Rewrite stack trace frames from "{PATH}.lua:{LINE}" to "{PATH}.ts:{ORIGINAL_LINE}".
53+
// https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1665
54+
// Avoid matching anonymous function stack entries like `in function <...>`
55+
// by excluding `<` before the file path.
56+
// TODO: This will still fail for paths containing spaces.
57+
let [result] = string.gsub(trace, "([^%s<]+)%.lua:(%d+)", (file, line) =>
5358
replacer(`${file}.lua`, `${file}.ts`, line)
5459
);
5560

0 commit comments

Comments
 (0)