lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

LÖVE: False Warning on love.keyboard.isDown() Despite Valid KeyConstant

Open dengmahal opened this issue 8 months ago • 4 comments
trafficstars

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows

What is the issue affecting?

Other

Expected Behaviour

when using love.keyboard.isDown("f4") or love.keyboard.isDown("f5") it shouldn't show a warning since those are valid KeyConstants in löve2d

Actual Behaviour

love.keyboard.isDown("f4") does not show a warning , but love.keyboard.isDown("f5") does show: Cannot assign string to parameter "!"|"#"|"$"|"&"|"'"...(+139).

  • string cannot match "!"|"#"|"$"|"&"|"'"...(+139)
  • string cannot match any subtypes in "!"|"#"|"$"|"&"|"'"...(+139)
  • Literal "f5" cannot match string "f2"
  • Literal "f5" cannot match string "f1"
  • Literal "f5" cannot match string "delete"
  • Literal "f5" cannot match string "return"
  • Literal "f5" cannot match string "clear"
  • Literal "f5" cannot match string "tab"
  • Literal "f5" cannot match string "backspace"
  • Literal "f5" cannot match string "insert"
  • Literal "f5" cannot match string "pagedown"
  • Literal "f5" cannot match string "pageup" ...(+84)
  • Literal "f5" cannot match string "c"
  • Literal "f5" cannot match string "b"
  • Literal "f5" cannot match string "a"

Reproduction steps

.

Additional Notes

whilst it shows a warning when using some KeyKonstants, it is autocompleting for all of them. It appears to show the error only for KeyConstants that are defined after "f4" is in "keyboard.lua".

Log File

No response

dengmahal avatar Mar 21 '25 21:03 dengmahal

I am experiencing the same issue on VSCode + sumneko.lua extension.

love.keyboard.isDown('escape') emits the warning as well as 'f5', just like in the original ticket.

isScancodeDown has the same issue with different values: love.keyboard.isScancodeDown('up')

grillonbleu avatar May 20 '25 22:05 grillonbleu

This is an issue with any function receiving parameters with type love.KeyConstant or love.Scancode. It actually happens with any type composed of a large union of literal strings. The 98th and every subsequent string of the union will emit a warning.

The limit on large unions might could be causing this issue: c8ed1981e7e4e7046ea1e6fb80ba7c58848cfe86

Unfortunately this performance measure seems to be clashing with the love2d api.

grillonbleu avatar May 20 '25 23:05 grillonbleu

duplicated as https://github.com/LuaLS/lua-language-server/issues/3178

But it seems that this should be the first one 😂 as it was created first

tomlau10 avatar May 21 '25 13:05 tomlau10

this is a show-stopper level problem for the Factorio api as well. it would be really great if this could get some attention...

justarandomgeek avatar Jun 18 '25 14:06 justarandomgeek