LuaLS / LuaLS/lua-language-server
Two Rule Suggestions: multiple returns in function calls / table definitions and string concatenation
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Lua
- Sterne
- 4.4k
- Forks
- 442
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
### multiple returns in function calls / table definitions
```lua
local a = { "one", "two", "three" }
local b = { unpack(a), "four" }
local c = { "four", unpack(a) }
print(#b) -- 2
print(#c) -- 4
```
`unpack`'s behavior is quite unintuitive; when the output is not in the last position of a table definition, only the first element is actually included in the new table. (In fact, this not only applies to `unpack`, but to every function that returns multiple values – only happens most often with `unpack` that will people will notice, I assume.)
see explainer in the docs: https://www.lua.org/manual/5.3/manual.html#3.4
I think a diagnostic that reminds one of such cases would be very useful, since it's a common gotcha in lua.
## string concatenation
```lua
print("foo" + "bar")
```
Common mistake to not use `..` for string concatenation. Even though I am used to lua, it still happens to me all the time after coming back from writing in a different language. A diagnostic here would be useful. (And I am actually a bit surprised that there isn't one yet.)
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem im Issue verlinkten Abschnitt des Lua-5.3-Handbuchs, insbesondere mit den Regeln für mehrere Rückgabewerte, die anhand der Tabellenbeispiele veranschaulicht werden. Suche dann die Diagnose-Einstiegspunkte des Language Servers für Ausdrücke mit mehreren Rückgabewerten in Tabellendefinitionen und für die Verwendung von + mit Strings. Als erledigt gilt die Aufgabe, wenn beide Beispiele nützliche Diagnosen erzeugen, ohne gültigen Lua-Code fälschlicherweise zu markieren.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- lua
- Bereich
- devtools
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 42/100