LuaLS / LuaLS/lua-language-server
Enhancement ---@fieldread, ---@fieldwrite or attribute modifiers on typing
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 4.4k
- Forks
- 442
- PR merge metrics
- No merged PRs in 30d
Description
When using some c api's (In my case Factorio's modding api) when you retrieve a value you get one type, but you can set it with multiple different types.
```lua
---@class Surface
---@class Player
local Player = {}
---@fieldread surface Surface
---@fieldwrite surface Surface|string
local p = Player.surface --- p is Surface
p.surface = "Other Surface" --No warnings
```
Another thought I had was attribute types, which would more easily support more attributes in the future
```lua
---@field{read} surface Surface
---@field{write} surface Surface|string
---@field{read,write} surface -- the default if no attributes are supplied
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no files, tests, or entry points. Start by locating the language server's handling of Lua field annotations and type checking, then compare the proposed @fieldread/@fieldwrite and attribute syntaxes with existing annotation behavior. Done means a decided syntax supports distinct read and write types and produces the expected warning behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100