love2d-community / love-api

The whole LÖVE wiki in a Lua table.
http://love2d-community.github.io/love-api/
299 stars 46 forks source link

Compatible with Lua 5.4 #97

Closed sumneko closed 3 years ago

sumneko commented 3 years ago

In Lua 5.4, require will return more than one return value, causing unexpected values to be inserted into the array.

love 5 4

sumneko commented 3 years ago

I found this problem in many places. I think we need a more elegant way to solve this problem.

MikuAuahDark commented 3 years ago

A proper way to discard the 2nd value is to wrap them in parenthesis, like {..., (require("something")), ...}. You probably need to do that in many places however.

Not sure how your lua-language-server handle such cases however.

sumneko commented 3 years ago

I'm not sure if this problem needs to be solved, because I may be the only one who use Lua 5.4 to load this file. And I have solved this problem by simulating the behavior of Lua 5.1: https://github.com/sumneko/lua-language-server/blob/bc6dd9b20925d21e6def32170854b27f69ca50d9/tools/love-api.lua#L4-L5