summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/core/diagnostics/duplicate-doc-alias.lua4
-rw-r--r--script/parser/luadoc.lua1
-rw-r--r--test/diagnostics/duplicate-doc-alias.lua11
3 files changed, 15 insertions, 1 deletions
diff --git a/script/core/diagnostics/duplicate-doc-alias.lua b/script/core/diagnostics/duplicate-doc-alias.lua
index 360358e4..6d8593ca 100644
--- a/script/core/diagnostics/duplicate-doc-alias.lua
+++ b/script/core/diagnostics/duplicate-doc-alias.lua
@@ -15,6 +15,7 @@ return function (uri, callback)
return
end
+ local merged = {}
local cache = {}
for _, doc in ipairs(state.ast.docs) do
if doc.type == 'doc.alias'
@@ -36,10 +37,11 @@ return function (uri, callback)
finish = otherDoc.finish,
uri = guide.getUri(otherDoc),
}
+ merged[name] = merged[name] or vm.docHasAttr(otherDoc, 'merge')
end
end
end
- if #cache[name] > 1 then
+ if not merged[name] and #cache[name] > 1 then
callback {
start = (doc.alias or doc.enum).start,
finish = (doc.alias or doc.enum).finish,
diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua
index 242b878e..bbffed25 100644
--- a/script/parser/luadoc.lua
+++ b/script/parser/luadoc.lua
@@ -1026,6 +1026,7 @@ local docSwitch = util.switch()
local result = {
type = 'doc.alias',
}
+ result.docAttr = parseDocAttr()
result.alias = parseName('doc.alias.name', result)
if not result.alias then
pushWarning {
diff --git a/test/diagnostics/duplicate-doc-alias.lua b/test/diagnostics/duplicate-doc-alias.lua
index 0373fee9..5a208e3e 100644
--- a/test/diagnostics/duplicate-doc-alias.lua
+++ b/test/diagnostics/duplicate-doc-alias.lua
@@ -8,3 +8,14 @@ TEST [[
---@class B
---@alias <!A!> B
]]
+
+TEST [[
+---@alias A integer
+---@alias(merge) A integer
+
+---@enum B
+---@enum(merge) B
+
+---@enum(key) C
+---@enum(key, merge) C
+]]