Skip to content

Add field completion for generic table literals - #3506

Open
NathanSnail wants to merge 2 commits into
LuaLS:masterfrom
NathanSnail:generic_suggestions
Open

NathanSnail wants to merge 2 commits into
LuaLS:masterfrom
NathanSnail:generic_suggestions

Conversation

@NathanSnail

Copy link
Copy Markdown
Contributor

No description provided.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

中文:发现以下可操作问题:

  1. 测试用例 NumberRange 缺少泛型参数,可能导致测试本身无效
    第一个测试中 ---@class NumberRange 没有声明泛型参数 <T>,但字段 min T / max T 引用了未声明的 T。这可能在编译期被当作未知类型处理,从而无法真正验证"普通 table literal 注释补全"这一回归路径,或者产生误导性的通过。建议确认为什么这里不声明 <T>,或者改成非泛型的具体类型(如 min number)来明确第一个测试只是验证基础 table 注释补全,而非泛型逻辑。

  2. 未覆盖 array 类型和 doc.type.sign 的补全测试
    编译器改动同时允许了 doc.type.table、doc.type.array 和新增的 doc.type.sign 三种类型设置节点,但测试只覆盖了 table({} 字面量)。建议补充 array 字面量(如 ---@type Range<number> 配合 { ... } 数组风格)以及可能触发 doc.type.sign 的场景,确保新增分支不会引入回归。

  3. changelog 描述与实际改动范围不完全一致
    changelog 只提到"instantiated generic type"的 table literal 补全修复,但代码改动同时影响了 doc.type.array 和 doc.type.sign 的节点设置行为。这是行为扩展而非纯修复,建议 changelog 措辞更准确地反映改动范围,或确认 doc.type.sign 分支的必要性并加以说明。

English: The following actionable issues were found:

  1. The NumberRange test case lacks generic parameters, which may make the test ineffective
    In the first test, ---@class NumberRange does not declare a generic parameter <T>, yet fields min T / max T reference an undeclared T. This may be treated as an unknown type at compile time, meaning it cannot actually verify the regression path of "plain table literal annotation completion", or it may produce a misleading pass. Confirm why <T> is intentionally omitted here, or change it to concrete non-generic types (e.g. min number) to make clear that the first test only verifies basic table annotation completion rather than generic logic.

  2. No completion tests cover array types or doc.type.sign
    The compiler change allows node setting for doc.type.table, doc.type.array, and the newly added doc.type.sign, but the tests only cover table ({}) literals. Add tests for array-style literals (e.g. ---@type Range<number> with array-style { ... }) and scenarios that could trigger doc.type.sign, to ensure the new branch doesn't introduce regressions.

  3. Changelog description does not fully match the actual change scope
    The changelog only mentions a fix for table literal completion with "instantiated generic type", but the code change also affects node-setting behavior for doc.type.array and doc.type.sign. This is a behavior extension rather than a pure fix; the changelog wording should more accurately reflect the change scope, or the necessity of the doc.type.sign branch should be confirmed and documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant