Skip to content

Commit c853e8c

Browse files
committed
emmylua_check: fix warnings
1 parent 6adbebe commit c853e8c

7 files changed

Lines changed: 18 additions & 0 deletions

File tree

tests/lapi/lib.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ local function bitwise_op(op_name)
6363
return function(...)
6464
local n = select("#", ...)
6565
assert(n > 0)
66+
---@type string
6667
local chunk
6768
-- Bitwise exclusive OR and bitwise NOT have the same
6869
-- operator.
@@ -76,6 +77,9 @@ local function bitwise_op(op_name)
7677
local op_name_ws = (" %s "):format(op_name)
7778
chunk = "return " .. table.concat({...}, op_name_ws)
7879
end
80+
-- `load` accepts a reader function or a Lua literal chunk
81+
-- type, not a dynamically built string; the call is valid.
82+
---@diagnostic disable-next-line: param-type-mismatch
7983
return assert(load(chunk))()
8084
end
8185
end

tests/lapi/math_log_test.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ local test_lib = require("lib")
2222
-- Libraries.
2323
--
2424
-- 1. https://www.lua.org/manual/5.3/manual.html
25+
---@type fun(x: number, y: number): number
2526
local pow
2627
if test_lib.lua_current_version_ge_than(5, 3) then
2728
pow = test_lib.math_pow

tests/lapi/string_gmatch_test.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ local function TestOneInput(buf, _size)
2525
local s = fdp:consume_string(test_lib.MAX_STR_LEN)
2626
local pattern = fdp:consume_string(test_lib.MAX_STR_LEN)
2727
local init = fdp:consume_integer(0, test_lib.MAX_INT)
28+
-- The `init` parameter is a Lua 5.4 extension; the emmylua stdlib
29+
-- model is configured for LuaJIT, which knows only two parameters.
30+
---@diagnostic disable-next-line: redundant-parameter
2831
string.gmatch(s, pattern, init)
2932
end
3033

tests/lapi/table_sort_test.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ local test_lib = require("lib")
1717
local MIN_INT = test_lib.MIN_INT64
1818
local MAX_INT = test_lib.MAX_INT64
1919

20+
---@return (integer | string)[]
2021
local function random_table(fdp, n)
2122
local count = fdp:consume_integer(0, n)
2223
local item_type = fdp:oneof({ "number", "string" })

tests/lapi/utf8_codepoint_test.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ local function TestOneInput(buf)
2727
local j = fdp:consume_integer(0, MAX_INT)
2828
local lax = fdp:consume_boolean()
2929
os.setlocale(test_lib.random_locale(fdp), "all")
30+
-- The `lax` parameter is a Lua 5.4 extension; the emmylua stdlib
31+
-- model is configured for LuaJIT and counts arguments loosely.
32+
---@diagnostic disable-next-line: redundant-parameter
3033
pcall(utf8.codepoint, s, i, j, lax)
3134
end
3235

tests/lapi/utf8_codes_test.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ local function TestOneInput(buf)
2828
local s = fdp:consume_string(max_len)
2929
local lax = fdp:consume_boolean()
3030
os.setlocale(test_lib.random_locale(fdp), "all")
31+
-- The `lax` parameter is a Lua 5.4 extension; the emmylua stdlib
32+
-- model is configured for LuaJIT and counts arguments loosely.
33+
---@diagnostic disable-next-line: redundant-parameter
3134
pcall(utf8.codes, s, lax)
3235
end
3336

tests/lapi/utf8_len_test.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ local function TestOneInput(buf)
2727
local j = fdp:consume_integer(0, MAX_INT)
2828
local lax = fdp:consume_boolean()
2929
os.setlocale(test_lib.random_locale(fdp), "all")
30+
-- The `lax` parameter is a Lua 5.4 extension; the emmylua stdlib
31+
-- model is configured for LuaJIT and counts arguments loosely.
32+
---@diagnostic disable-next-line: redundant-parameter
3033
pcall(utf8.len, s, i, j, lax)
3134
end
3235

0 commit comments

Comments
 (0)