summaryrefslogtreecommitdiff
path: root/test/diagnostics
diff options
context:
space:
mode:
Diffstat (limited to 'test/diagnostics')
-rw-r--r--test/diagnostics/common.lua150
-rw-r--r--test/diagnostics/type-check.lua1
2 files changed, 149 insertions, 2 deletions
diff --git a/test/diagnostics/common.lua b/test/diagnostics/common.lua
index a1dbe819..d061b4e4 100644
--- a/test/diagnostics/common.lua
+++ b/test/diagnostics/common.lua
@@ -156,13 +156,13 @@ print(A) -- no warning
TEST [[
---@type iolib
-_ENV = {}
+_ENV = io
<!print!>(stderr) -- `print` is warning but `stderr` is not
]]
TEST [[
---@type iolib
-local _ENV = {}
+local _ENV = io
<!print!>(stderr) -- `print` is warning but `stderr` is not
]]
@@ -2206,6 +2206,7 @@ end
TEST [[
---@diagnostic disable: unused-local
+---@diagnostic disable: missing-fields
---@class A
---@field private x number
local mt = {}
@@ -2220,6 +2221,7 @@ end
TEST [[
---@diagnostic disable: unused-local
+---@diagnostic disable: missing-fields
---@class A
---@field private x number
local mt = {}
@@ -2268,3 +2270,147 @@ local function foo(_ENV)
Joe = "human"
end
]]
+
+TEST [[
+---@diagnostic disable: unused-local
+---@class A
+---@field x number
+---@field y? number
+---@field z number
+
+---@type A
+local t = <!{}!>
+]]
+
+TEST [[
+---@diagnostic disable: unused-local
+---@class A
+---@field x number
+---@field y? number
+---@field z number
+
+---@type A
+local t = <!{
+ x = 1,
+}!>
+]]
+
+TEST [[
+---@diagnostic disable: unused-local
+---@class A
+---@field x number
+---@field y? number
+---@field z number
+
+---@type A
+local t = <!{
+ x = 1,
+ y = 2,
+}!>
+]]
+
+TEST [[
+---@diagnostic disable: unused-local
+---@class A
+---@field x number
+---@field y? number
+---@field z number
+
+---@type A
+local t = {
+ x = 1,
+ y = 2,
+ z = 3,
+}
+]]
+
+TEST [[
+---@diagnostic disable: unused-local
+---@class A
+---@field x number
+---@field y? number
+---@field z number
+
+---@type A
+local t = {
+ x = 1,
+ z = 3,
+}
+]]
+
+TEST [[
+---@diagnostic disable: unused-local
+---@class A
+---@field x number
+---@field y? number
+---@field z number
+
+---@param a A
+local function f(a) end
+
+f <!{}!>
+]]
+
+TEST [[
+---@diagnostic disable: unused-local
+---@class A
+---@field x number
+---@field y? number
+---@field z number
+
+---@param a A
+local function f(a) end
+
+f <!{
+ x = 1,
+}!>
+]]
+
+TEST [[
+---@diagnostic disable: unused-local
+---@class A
+---@field x number
+---@field y? number
+---@field z number
+
+---@param a A
+local function f(a) end
+
+f <!{
+ x = 1,
+ y = 2,
+}!>
+]]
+
+TEST [[
+---@diagnostic disable: unused-local
+---@class A
+---@field x number
+---@field y? number
+---@field z number
+
+---@param a A
+local function f(a) end
+
+f {
+ x = 1,
+ y = 2,
+ z = 3,
+}
+]]
+
+TEST [[
+---@diagnostic disable: unused-local
+---@class A
+---@field x number
+---@field y? number
+---@field z number
+
+---@param a A
+local function f(a) end
+
+f {
+ x = 1,
+ z = 3,
+}
+]]
diff --git a/test/diagnostics/type-check.lua b/test/diagnostics/type-check.lua
index dd9d1198..adfef561 100644
--- a/test/diagnostics/type-check.lua
+++ b/test/diagnostics/type-check.lua
@@ -174,6 +174,7 @@ m.ints = {}
]]
TEST [[
+---@diagnostic disable: missing-fields
---@class A
---@field x A