LuaLS / LuaLS/lua-language-server

hexdecimal literals not being parsed properly

Open
#2,929 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
4.4k
Forks
442
PR merge metrics
No merged PRs in 30d

Description

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Linux

What is the issue affecting?

Type Checking, Completion

Expected Behaviour
---@alias intent_value
---|0x1
---|0x2
---|0x4
---|0x8
---|0x10
---|0x20
---|0x40
---|0x80
---|0x100
---|0x200
---|0x400
---|0x800
---|0x1000
---|0x2000
---|0x4000
---|0x8000
---|0x10000
---|0x100000
---|0x200000

---@param t intent_value
local function a(t) end

a(<??>) -- expected suggestions: the hexadecimal literals
Actual Behaviour

image

Reproduction steps
  1. copy the above code
  2. try a completion for the a function.
Additional Notes

I am somewhat confused at this because... it is doing something but not exactly?
The linter seems to understand this is a numeric literal, but the language server seems to only take the 0 value, and the actual value seems to be treated as a comment instead of a value, probably because it is not parsing it properly?

Log File

No response

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

Begin with the provided Lua reproduction and inspect how the language server parses hexadecimal values in the @alias and uses them for completion at a(...). Reproduce the missing hexadecimal-literal suggestions in the Visual Studio Code extension, then verify that the listed values are recognized as distinct numeric options and that type checking still accepts intent_value arguments.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.