summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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?>
+]]