Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined field gsub for string:gsub #567

Closed
serg3295 opened this issue Jun 21, 2021 · 1 comment
Closed

Undefined field gsub for string:gsub #567

serg3295 opened this issue Jun 21, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@serg3295
Copy link
Contributor

Describe the bug
luasrv_err34

To Reproduce

local optparam = {}
local allop = {}
for op in string.gmatch(allop, "[%[%s]+([%s%w_\1\2\3]+)[%[%]]") do
  optparam[#optparam + 1]  = op :gsub("\1", ",")
                                :gsub("\2", "[")
                                :gsub("\3", "]")
end

Environment (please complete the following information):

  • OS: Linux Mint
  • Is WSL remote?
  • Client: VSCode
@Avril112113
Copy link

Avril112113 commented Jun 22, 2021

I am having the same issue in multiple places in my own code.
Looking into this more it's a bit strange when it happens, here is a list of minimal examples of what I've found so far so work and not work
image

local str = "123"

local working1 = str:gsub("0", "1"):gsub("1", "2"):gsub("2", "3")

local broken1 = str:sub(2, -1):gsub("1", "2"):gsub("2", "3")
local working2 = str:gsub("0", "1"):sub(2, -1):gsub("1", "2"):gsub("2", "3")

local broken2 = str:gmatch("%d")():gsub("1", "2"):gsub("2", "3")
local working3 = str:gsub("1", "2"):gmatch("%d")():gsub("1", "2"):gsub("2", "3")

Extra note: no errors in the log file

@sumneko sumneko added the bug Something isn't working label Jun 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants