You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Stylua 0.20.0. I wish I had a minimum repro but the very obvious repros aren't triggering it I'm afraid so the block of code is longer.
Why it matters: we can't use the official GH action to reliably format code containing labels because it enables luau, and there don't seem to be variants to let us use another asset or something like that to only have the lua variants.
Anyhow:
cargo install stylua --features lua52,luau
On both formatting and checking, we get:
error: could not format file .\scripts\memosort.lua: error parsing: error occurred while creating ast: unexpected token `end`. (starting from line 41, character 4 and ending on line 41, character 7)
additional information: expected identifier after `::`
And the code, as minimal as I could get it:
local mod = {}
---@alias fa.memosort.ScoreCallback fun(any): number
---@param tab any[]
---@param callback fa.memosort.ScoreCallback
---@param cache table?
function mod.memosort(tab, callback, cache)
cache = cache or {}
for i = 1, #tab do
if cache[tab[i]] then goto continue end
cache[tab[i]] = callback(tab[i])
::continue::
end
table.sort(tab, function(a, b)
assert(cache[a])
assert(cache[b])
return cache[a] < cache[b]
end)
end
return mod
This is the Lua "continue idiom": ::continue:: as a label and goto continue. I did think okay it's a keyword so let's rename it. ::cont::, but that didn't work either. And I'm sure it doesn't trigger on all labels--it certainly didn't on small test cases.
Note that Luau itself dropped goto. Not sure if that's relevant to the problem but I did also check that.
The text was updated successfully, but these errors were encountered:
This is a duplicate of #407. It will be fixed by #854 which will introduce a way to configure the style of syntax used at runtime in the stylua.toml file
Stylua 0.20.0. I wish I had a minimum repro but the very obvious repros aren't triggering it I'm afraid so the block of code is longer.
Why it matters: we can't use the official GH action to reliably format code containing labels because it enables luau, and there don't seem to be variants to let us use another asset or something like that to only have the lua variants.
Anyhow:
cargo install stylua --features lua52,luau
On both formatting and checking, we get:
And the code, as minimal as I could get it:
This is the Lua "continue idiom":
::continue::
as a label and goto continue. I did think okay it's a keyword so let's rename it.::cont::
, but that didn't work either. And I'm sure it doesn't trigger on all labels--it certainly didn't on small test cases.Note that Luau itself dropped goto. Not sure if that's relevant to the problem but I did also check that.
The text was updated successfully, but these errors were encountered: