LuaLS / LuaLS/lua-language-server

Operators can only be defined one way

Open
#1,371 14 comments 4 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

Describe the bug
Its seems like operators can only be defined one way? I want number * Vec3 to be Vec3. Am I missing something?

To Reproduce

    --- @class Vec3
    --- @operator mul(number): Vec3
    local Vec3 = {}

    local t1 = Vec3() * 2 ---Vec3
    local t2 = 2 * Vec3() --Integer!

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

Start by reproducing the Lua example in the issue, comparing Vec3() * 2 with 2 * Vec3(). Trace the language-server operator annotation handling and define completion as making both operand orders infer Vec3 consistently, with regression coverage for the shown cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.