Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Annotations in inline comments do not recognize others on the same line

未关闭
#3,350 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
lua
领域
devtools

调研方向

使用报告中的内联 Lua 注释示例在 VSCode 中复现该问题,然后比较拆分到多行的注释与同一行上的多个注释。跟踪 language server 如何关联相关注释,例如泛型、参数、返回值、类、字段和别名;当同一行上的注释与单独成行的注释得到一致解释时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Linux

What is the issue affecting?

Annotations, Type Checking

Expected Behaviour

Placing multiple annotations in inline comments like so works fine: the generics are interpreted correctly.

--[[@generic C]]
--[[@param any C]]
--[[@return C]]
local function exampleGeneric(any) return any end

So one would expect grouping them together on the same line (like this) would also work:

--[[@generic C]] --[[@param any C]] --[[@return C]]
local function exampleGeneric(any) return any end
Actual Behaviour

In the previous example, the generic seems to be defined, but doesn't carry over properly to the other two annotations. Similarly, adding a line break between the first and second annotation like this

--[[@generic C]]
--[[@param any C]] --[[@return C]]
local function exampleGeneric(any) return any end

allows the generic to be recognized by the second annotation, but not the third. This behavior is also visible in other annotations that require others to be nearby, such as with classes and fields, and aliases.

Reproduction steps
  1. Open VSCode
  2. Paste either of the following examples into an empty lua file:
--[[@class amazingClass]] --[[@field field1 string]] --[[@field field2 number]]
--[[@generic C]] --[[@param any C]] --[[@return C]]
local function exampleGeneric(any) return any end
Additional Notes

While I realize there is little practical use for some of these cases, such as the class definition (as it starts to take up a lot of horizontal space really quickly when defining new fields), this is especially useful when creating a plugin that allows for inline annotation definitions like the following:

local width: integer, height: integer = screen.width, screen.height
local logo: love.Image = textures["logo.png"]

which generates inline comments like so in order to preserve syntax coloring, as well as line numbers during runtime:

local width --[[@type integer ]], height --[[@type integer ]] = screen.width, screen.height
local logo --[[@type love.Image ]] = textures["logo.png"]
Log File

No response

主要语言
Lua
星标
4.4k
派生
442
平均合并
8 天 9 小时
30 天内合并 PR
1

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

LuaLS/lua-language-server 的其他 Issue

查看 LuaLS/lua-language-server 的全部 Issue

相似的 Issue

更多 Lua Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。