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

[odinfmt] weird return {...} struct formatting #346

Closed
jakubtomsu opened this issue Apr 15, 2024 · 4 comments
Closed

[odinfmt] weird return {...} struct formatting #346

jakubtomsu opened this issue Apr 15, 2024 · 4 comments

Comments

@jakubtomsu
Copy link

A return statement with a multiline struct initializer gets formatted weirdly.

Here is an example. This is the what it should look like:

return {
	alloc_fn = allocator_alloc_func,
	free_fn = allocator_free_func,
	user_data = cast(rawptr)context_ptr,
}

And here is what it gets formatted into:

return(
	 {
		alloc_fn = allocator_alloc_func,
		free_fn = allocator_free_func,
		user_data = cast(rawptr)context_ptr,
	} \
)

The parentheses and backslash don't look very good...

@DanielGavin
Copy link
Owner

DanielGavin commented Apr 15, 2024

The format style was thought for:

return(
	imp1.derived.(^ast.Import_Decl).fullpath <
	imp2.derived.(^ast.Import_Decl).fullpath \
)

Instead it would have to be

return imp1.derived.(^ast.Import_Decl).fullpath <
       imp2.derived.(^ast.Import_Decl).fullpath \

OR

return 
    imp1.derived.(^ast.Import_Decl).fullpath <
    imp2.derived.(^ast.Import_Decl).fullpath \

Maybe that should be changed aswell, but with braces I agree it makes no sense.

@jakubtomsu
Copy link
Author

I think this looks the best:

return imp1.derived.(^ast.Import_Decl).fullpath <
       imp2.derived.(^ast.Import_Decl).fullpath \

The braces do make things a bit clearer, but it's not something I would write without odinfmt. I'm not entirely sure but I think the core: libs don't use them as well.

@Feoramund
Copy link
Contributor

Looks to be a duplicate of #271.

@DanielGavin
Copy link
Owner

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants