Skip to content

Commit ccae8fd

Browse files
committed
fix(lualib): select() call was not using vararg optimization, breaking some spead cases
1 parent e187193 commit ccae8fd

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/lualib/CountVarargs.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import { __TS__IsLua50 } from "./IsLua50";
44

55
export function __TS__CountVarargs<T>(...args: T[]): number {
6-
// In Lua 5.0, the arg table includes trailing nils. In all other
7-
// versions, we must use select() to count trailing nils.
8-
return __TS__IsLua50 ? args.length : select("#", ...args);
6+
// select() is not available in Lua 5.0. In that version, the arg table
7+
// includes trailing nils.
8+
// It is important that the select() branch come first as we need vararg
9+
// optimization for this call.
10+
return !__TS__IsLua50 ? select("#", ...args) : args.length;
911
}

0 commit comments

Comments
 (0)