typedlua icon indicating copy to clipboard operation
typedlua copied to clipboard

attempt to index '(string)' with '"gsub"'

Open Zash opened this issue 8 years ago • 2 comments

local function a(s:string):string
  return (s:lower():gsub("a","b"));
end

should be equivalent to string.gsub(s:lower(), "a", "b") and string.gsub(string.lower(s), "a", "b") but gives a type error.

Zash avatar Nov 16 '16 15:11 Zash

You're right; there appears to be a bug in the compiler for the : operator.

As a workaround, it works when you wrap the first member-call in brackets (although this should make no difference to Lua):

(s:lower()):gsub("a", "b")

Veltas avatar Nov 16 '16 16:11 Veltas

This is a completely nonsense report, something is clearly broken here:

("a"):gsub("a", "b"):lower()
attempt to index '(string, integer)' with '"lower"'

Veltas avatar Nov 16 '16 16:11 Veltas