LuaLS / LuaLS/lua-language-server

Parser gets confused by stray commas

Aperta
#2,564 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Lua
Stelle
4.4k
Fork
442
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo l’esempio Lua con le due righe di assegnazione e ispeziona il percorso del parser che produce err-equal-as-assign e redundant-value. Il problema è risolto quando la virgola estranea viene segnalata come l’errore pertinente invece di produrre queste diagnosi fuorvianti.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
lua
Ambito
compilers
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.