summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2024-04-18 17:00:11 +0800
committer最萌小汐 <sumneko@hotmail.com>2024-04-18 17:00:11 +0800
commitd11925853f6dd02ae5684a587257fd9b29202771 (patch)
tree36262a2aea813d2b7a43f35220c52e83cd9d81c7
parentb20367454f31cc178020ee8a0e34fe0a18ddbb01 (diff)
downloadlua-language-server-d11925853f6dd02ae5684a587257fd9b29202771.zip
补充测试和更新说明
-rw-r--r--changelog.md31
-rw-r--r--script/parser/luadoc.lua2
-rw-r--r--test/type_inference/init.lua9
3 files changed, 40 insertions, 2 deletions
diff --git a/changelog.md b/changelog.md
index 20110331..50e719d8 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,6 +1,37 @@
# changelog
## 3.7.5
+* `NEW` alias and enums supports attribute `merge`
+ ```lua
+ ---@alias Animal Cat
+
+ ---@alias(merge) Animal Dog
+
+ ---@type Animal
+ local animal --> animal is `Cat|Dog` here
+ ```
+
+ ```lua
+ ---@enum(key) ErrorCodes
+ local codes1 = {
+ OK = 0,
+ ERROR = 1,
+ FATAL = 2,
+ }
+
+ ---@enum(key, merge) ErrorCodes
+ local codes2 = {
+ WARN = 3,
+ INFO = 4,
+ }
+
+ ---@type ErrorCodes
+ local code
+
+ code = 'ERROR' --> OK
+ code = 'WARN' --> OK
+
+ ```
* `FIX` rename in library files
## 3.7.4
diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua
index bbffed25..7fd73c91 100644
--- a/script/parser/luadoc.lua
+++ b/script/parser/luadoc.lua
@@ -1026,7 +1026,7 @@ local docSwitch = util.switch()
local result = {
type = 'doc.alias',
}
- result.docAttr = parseDocAttr()
+ result.docAttr = parseDocAttr(result)
result.alias = parseName('doc.alias.name', result)
if not result.alias then
pushWarning {
diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua
index 98a07ca3..093cfb1e 100644
--- a/test/type_inference/init.lua
+++ b/test/type_inference/init.lua
@@ -4335,4 +4335,11 @@ end
local <?x?> = f()
]=]
---
+
+TEST 'boolean|number' [[
+---@alias A number
+---@alias(merge) A boolean
+
+---@type A
+local <?x?>
+]]