Studio debugger should tell me which subexpression is throwing

I have an if statement that calls two functions. I can’t tell which one is failing by looking at the output from the Studio debugger.

It would be cool if the output pane said which function call was not getting the arguments it expected.

I know Studio knows, since adding a line disambiguates.

image

6 Likes

You are using string:sub when you should be using string.sub. The error is a bit unintuitive as : is passing “itself” to the function sub causing the first argument to be a table and not the string (which will now be the second).

There is no access for Roblox / Lua internal functions so you are not able to step into the function call.

A quick example

local foo = {}

function foo:bar()
	return true -- can step into
end

local part = Instance.new('Part')
local a = 'foo'

-- can only debug function bar
if foo:bar() and part:IsA('Part') and string.sub(a, 1, 3) == 'foo' then -- breakpoint
	
end
2 Likes

Yeah I know what the bug is, I just don’t want to have to break up my code into different lines to get Studio to tell me which subexpression is wrong.

7 Likes

Yeah this was in the backlog for a little bit; the issue isn’t so much the error location, but that the error message here needs to be more descriptive.