Lua declarations: type registrations by their value type

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
30/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
lua, rust

调研方向

Start with the generated Lua declarations and the bindings used by World.get_type_by_name, get_component, get_resource, bms.construct, and get_asset; the issue gives no file paths. Check the LuaLS diagnostics from the stated --check run, then study the open pull request #661 and the type-table issue mentioned here. Done means registrations and values carry useful inferred types and the reported type mismatches and undefined-field diagnostics are addressed.

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

描述

Found by running LuaLS 3.19.2 --check over assets/tests/**/*.lua against declarations generated with all bevy_*_bindings features + lua54 + register_test_functions (454 problems in 92 files at the time).

Problem

Registrations carry no value type, so values from the world are untyped (~150 diagnostics).

  • World.get_type_by_name returns bms.ScriptTypeRegistration | bms.ScriptComponentRegistration | bms.ScriptResourceRegistration | bms.ScriptBundleRegistration | nil, while add_default_component, get_resource, insert_bundle, etc. take one specific registration → param-type-mismatch on nearly every test using a registration.
  • get_component / get_resource / bms.construct / get_asset return plain ReflectReference, so e.g. child_of:parent(), res.vec_usize, constructed.foo, reference:rotate_y(1.0) are undefined-field / inject-field.

Possible direction

Generic registrations (verified working in LuaLS, t infers transform.Transform|nil):

---@class bms.ScriptComponentRegistration<T> : ReflectReference
---@generic T
---@param registration bms.ScriptComponentRegistration<T>
---@return T | nil
function World.get_component(entity, registration) end

Open question: how a string lookup produces T — generated literal overloads per registered type on get_type_by_name, or only typing namespace type tables (see the type-table issue).

主要语言
Rust
星标
660
派生
59
平均合并
16 小时 23 分钟
30 天内合并 PR
61

环境准备

从这里开始

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

makspll/bevy_mod_scripting 的其他 Issue

查看 makspll/bevy_mod_scripting 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

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