fix(lua): relax vim.wait() timeout validation #36900

Problem:
After bc0635a9fc `vim.wait()` rejects floats
and NaN values.

Solution:
Restore the prior behavior, while still supporting `math.huge`. Update
tests to cover float case.
This commit is contained in:
skewb1k
2025-12-10 17:44:05 +03:00
committed by GitHub
parent d2e445e1bd
commit b87bdef2a8
4 changed files with 12 additions and 16 deletions

View File

@@ -456,15 +456,9 @@ static int nlua_wait(lua_State *lstate)
if (timeout_number < 0) {
return luaL_error(lstate, "timeout must be >= 0");
}
int64_t timeout;
if (isinf(timeout_number) || timeout_number > (double)INT64_MAX) {
timeout = INT64_MAX;
} else {
if (isnan(timeout_number) || timeout_number != trunc(timeout_number)) {
return luaL_error(lstate, "timeout has no integer representation");
}
timeout = (int64_t)timeout_number;
}
int64_t timeout = (isnan(timeout_number) || timeout_number > (double)INT64_MAX)
? INT64_MAX
: (int64_t)timeout_number;
int lua_top = lua_gettop(lstate);