Skip to content

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

@Hzj-jie

Description

@Hzj-jie

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions