Skip to content

Commit 975a0f7

Browse files
committed
fix for assertion when viewing globals on unstarted thread
1 parent d92d072 commit 975a0f7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

debugger/luafuncs.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,18 @@ export function loadLuaFile(
101101
}
102102

103103
export function luaGetEnv(level: number, thread?: LuaThread): Env | undefined {
104-
const info = thread ? luaAssert(debug.getinfo(thread, level, "f")) : luaAssert(debug.getinfo(level + 1, "f"));
105-
const func = luaAssert(info.func);
104+
const info = thread ? debug.getinfo(thread, level, "f") : debug.getinfo(level + 1, "f");
105+
if (!info || !info.func) {
106+
return;
107+
}
108+
106109
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
107110
if (getfenv !== undefined) {
108-
return getfenv(func) as Env | undefined;
111+
return getfenv(info.func) as Env | undefined;
109112
} else {
110113
let i = 1;
111114
while (true) {
112-
const [name, value] = debug.getupvalue(func, i);
115+
const [name, value] = debug.getupvalue(info.func, i);
113116
if (!name) {
114117
break;
115118
}

0 commit comments

Comments
 (0)