LuaLS / LuaLS/lua-language-server

Enhancement ---@fieldread, ---@fieldwrite or attribute modifiers on typing

Open
#1,298 2 comments 14 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
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.

---@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

---@field{read} surface Surface
---@field{write} surface Surface|string
---@field{read,write} surface -- the default if no attributes are supplied

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.