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

Code expression being merged into a comment after running formatting a few times #648

Closed
vegorov-rbx opened this issue Feb 10, 2023 · 1 comment · Fixed by #649
Closed
Labels
bug Something isn't working

Comments

@vegorov-rbx
Copy link

vegorov-rbx commented Feb 10, 2023

I have the following Lua/Luau function with some bad formatting and a strange choice of comment locations:

function foo(f, g, a, b, c)
	return f(a)
		or g(b and c
			-- a somewhat strange location to describe something
			or false
			-- yes, this newline might not have been intended
		)
end

After running StyLua 0.16.0 once, I get the following result:

function foo(f, g, a, b, c)
	return f(a)
		or g(
			b and c			-- a somewhat strange location to describe something
 or false
			-- yes, this newline might not have been intended
		)
end

If I run it again, or false expression gets embedded into the comment changing the meaning of the code ('g' can now be called with 'nil' if 'b' is 'nil'):

function foo(f, g, a, b, c)
	return f(a)
		or g(
			b and c -- a somewhat strange location to describe something or false
			-- yes, this newline might not have been intended
		)
end
@JohnnyMorganz
Copy link
Owner

Fix released in v0.16.1 https://github.com/JohnnyMorganz/StyLua/releases/tag/v0.16.1

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

Successfully merging a pull request may close this issue.

2 participants