LuaLS / LuaLS/lua-language-server

Parser gets confused by stray commas

Open
#2,564 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

Example:

```
L.FOO = "something",
L.BAR = "something else"
```

This triggers two unexpected diagnostics: err-equal-as-assign and redundant-value which is a bit confusing.

The reason is that it interprets this as that the user's intent was to write `FOO, (some other var) = "something", BAR == "something else"`

However, the actual error is a stray comma after the first line.

This error may sound a bit obscure, because why would add someone a stray comma? The answer is that this happened in a localization files where people who are not necessarily familiar with Lua are contributing translations. Sometimes these translations are given in table literals where they need to add commas after each line and sometimes they are given as a list of setfield statements...

This is probably not easy to fix because the parser's interpretation is completely valid until it encounteres the assignment...

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 with the two assignment lines and inspect the parser path that produces err-equal-as-assign and redundant-value. The issue is addressed when the stray comma is reported as the relevant error rather than producing those confusing diagnostics.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
compilers
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.