Luau auto indent breaking when using a table type {} in a function definition

When using Luau type syntax and you define a function like foo(a: {}), the auto indent drops one tab so you have to manually keep adding the format back in. However pressing enter or even pasting on a line that you have added the indent back on will remove it again.

This happens to every line after the table typing in the function declaration. Every line above that still works fine. This gets very annoying and time consuming when you have to keep formatting for every line you edit.

Very easy to reproduce. The following in a script will show the issue.
–!strict

local function foo(a: string): string
    	if type(a) == 'string' then
    		return "a is a string"
    	else
    		return "a is not a string"
    	end
    end

local function bar(a: {}): string	-- auto indent continues to work above this line but not below
	if type(a) == 'table' then
	return "a is a table"
	-- pressed enter at the end of the line above and lose an indent
	else
		return "a is not a table"
	end
end
2 Likes

Thanks for reporting! We’ve located issue and will fix it ASAP!

2 Likes


I’m still experiencing this issue as you can see from this video clip.

Problematic code:

function CharacterAddedHandler.addCallback(callbackFunction: () -> nil): number
	table.insert(callbacks, #callbacks + 1, callbackFunction)
	return #callbacks -- BREAKS HERE
end