Skip to content

Syntax error when formatting luau return type and trailing comment #608

@filiptibell

Description

@filiptibell

Formatting a function with a comment after a single return type enclosed in parentheses formats the code from something like this:

function foo(): (
	nil -- Some comment
)
	return nil
end

To this:

function foo(): (nil -- Some comment)
	return nil
end

The closing parentheses is now part of the comment and produces a syntax error.
StyLua could either enforce no parentheses on single return types or format it as the original code block when parentheses are found, either solution works IMO.

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