From 420812ce4e77ff4143437b2893dd77fc729c7622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 23 Jun 2022 03:32:57 +0800 Subject: update --- test/diagnostics/common.lua | 16 ++++++++++++++++ test/type_inference/init.lua | 27 +++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) (limited to 'test') diff --git a/test/diagnostics/common.lua b/test/diagnostics/common.lua index 0708f63a..a837fc0f 100644 --- a/test/diagnostics/common.lua +++ b/test/diagnostics/common.lua @@ -1659,3 +1659,19 @@ k(f()) TEST [[ ---@cast integer ]] + +TEST [[ +---@class A + +---@class B +---@field [integer] A +---@field [A] true +]] + +TEST [[ +---@class A + +---@class B +---@field [A] A +---@field [] true +]] diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua index bca3a546..434307a2 100644 --- a/test/type_inference/init.lua +++ b/test/type_inference/init.lua @@ -3016,3 +3016,30 @@ if type(x) == 'number' then print() end ]] + +TEST 'boolean' [[ +---@class A +---@field [integer] boolean +local mt + +function mt:f() + ---@type integer + local index + local = self[index] +end +]] + +TEST 'boolean' [[ +---@class A +---@field [B] boolean + +---@class B + +---@type A +local a + +---@type B +local b + +local = a[b] +]] -- cgit v1.2.3