Skip to content

Commit 716a237

Browse files
authored
fix sourceMapTraceback (#1087)
Co-authored-by: Benjamin Ye <24237065+enjoydambience@users.noreply.github.com>
1 parent a738dfc commit 716a237

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/lualib/SourceMapTraceBack.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// TODO: In the future, change this to __TS__RegisterFileInfo and provide tstl interface to
22
// get some metadata about transpilation.
3+
declare function __TS__originalTraceback(this: void, thread?: LuaThread, message?: string, level?: number);
34
function __TS__SourceMapTraceBack(this: void, fileName: string, sourceMap: { [line: number]: number }): void {
45
globalThis.__TS__sourcemap = globalThis.__TS__sourcemap || {};
56
globalThis.__TS__sourcemap[fileName] = sourceMap;

test/unit/printer/sourcemaps.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,15 @@ test("sourceMapTraceback saves sourcemap in _G", () => {
272272
}
273273
});
274274

275+
test("sourceMapTraceback gives traceback", () => {
276+
const builder = util.testFunction`
277+
return (debug.traceback as (this: void)=>string)();
278+
`.setOptions({ sourceMapTraceback: true, luaLibImport: tstl.LuaLibImportKind.Inline });
279+
280+
const traceback = builder.getLuaExecutionResult();
281+
expect(traceback).toEqual(expect.any(String));
282+
});
283+
275284
test("Inline sourcemaps", () => {
276285
const code = `
277286
function abc() {

0 commit comments

Comments
 (0)