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

Mistransformation when formatting a comment within a string concatenation chain #154

Closed
matthargett opened this issue May 12, 2021 · 1 comment · Fixed by #163
Closed
Labels
bug Something isn't working

Comments

@matthargett
Copy link

with stylua 0.8.0:

return function (defaultExport)
	if defaultExport == nil then
		print(
			"lazy: Expected the result of a dynamic import() call. " ..
				"Instead received: %s\n\nYour code should look like: \n  " ..
				-- Break up imports to avoid accidentally parsing them as dependencies.
				-- ROBLOX deviation: Lua syntax in message
	      "local MyComponent = lazy(function() => req" ..
				"quire('script.Parent.MyComponent') end)",
			moduleObject
		)
	end
end```

mistransforms into:
```lua
return function(defaultExport)
	if defaultExport == nil then
		print(
			"lazy: Expected the result of a dynamic import() call. "
				.. "Instead received: %s\n\nYour code should look like: \n  "
				.. 			-- Break up imports to avoid accidentally parsing them as dependencies.
			-- ROBLOX deviation: Lua syntax in message
"local MyComponent = lazy(function() => req"
				.. "quire('script.Parent.MyComponent') end)",
			moduleObject
		)
	end
end
@JohnnyMorganz JohnnyMorganz added the bug Something isn't working label May 12, 2021
@JohnnyMorganz
Copy link
Owner

Similar issue:

return function(defaultExport)
	if defaultExport == nil then
		print(
			"lazy: Expected the result of a dynamic import() call. "
				.. "Instead received: %s\n\nYour code should look like: \n  "
				-- Break up imports to avoid accidentally parsing them as dependencies.
				-- ROBLOX deviation: Lua syntax in message
				.. "local MyComponent = lazy(function() => req"
				.. "quire('script.Parent.MyComponent') end)",
			moduleObject
		)
	end
end

... gets formatted as ...

return function(defaultExport)
	if defaultExport == nil then
		print(
			"lazy: Expected the result of a dynamic import() call. "
				.. "Instead received: %s\n\nYour code should look like: \n  "
				.. "local MyComponent = lazy(function() => req"
				.. "quire('script.Parent.MyComponent') end)",
			moduleObject
		)
	end
end

i.e. leading comments to a binop are lost

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