StyLua icon indicating copy to clipboard operation
StyLua copied to clipboard

Combination of comment, quote, single quote and lambda introduces syntax error

Open Hzj-jie opened this issue 8 months ago • 0 comments

E.g.

hzj_jie@hzj-jie-x61t - Mon May 12-23:42:21:~/git/koreader-202411$ cat test.lua 
local function f()
  local a = "ab"
  a = a:gsub("a".. -- "
    'b', function() return "c" end)
  print(a)
end

f()

should return "c"

hzj_jie@hzj-jie-x61t - Mon May 12-23:42:20:~/git/koreader-202411$ luajit test.lua 
c

By using the following version and stylua.toml,

hzj_jie@hzj-jie-x61t - Mon May 12-23:42:32:~/git/koreader-202411$ ./stylua --version
stylua 2.1.0
hzj_jie@hzj-jie-x61t - Mon May 12-23:42:49:~/git/koreader-202411$ cat stylua.toml 
syntax = "LuaJIT"
column_width = 80
indent_type = "Spaces"
indent_width = 2

stylua causes a syntax error,

hzj_jie@hzj-jie-x61t - Mon May 12-23:42:25:~/git/koreader-202411$ ./stylua test.lua 
hzj_jie@hzj-jie-x61t - Mon May 12-23:42:29:~/git/koreader-202411$ cat test.lua 
local function f()
  local a = "ab"
  a = a:gsub("a" ..  -- ""b", function()
    return "c"
  end)
  print(a)
end

f()

Thank you.

Hzj-jie avatar May 13 '25 06:05 Hzj-jie