-
Notifications
You must be signed in to change notification settings - Fork 58
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
Assignments not aligned when using bit_set #294
Comments
Here's another repo Foo :: struct {
A: string,
BBB: string,
CCCCC: Bar,
DD: Baz,
EEEE: int,
}
Bar :: struct {
A: string,
BBB: string,
}
Baz :: bit_set[BazFlag]
BazFlag :: enum {
A,
B,
C,
}
main :: proc() {
// aligned
foo := Foo {
A = "foo",
BBB = "bar",
EEEE = 42,
}
// unaligned
bar := Foo {
A = "foo",
BBB = "bar",
CCCCC = Bar{},
}
baz := Foo {
A = "foo",
BBB = "bar",
DD = {},
}
} The alignment of consecutive assignments within the aggregate initializer changes to unaligned when there's a nested brace of some sort. Is this intentional or unwarranted? |
The aggregate initializer currently disables alignment, because I'm worried of having to align stuff like this:
It's both quite hard to align this correctly. There could even more than just one nest of braces. But in your example there is no named assignments in the aggregate initializer, so it could be possible to have it align anyway for that case. Making that exception probably helps for most cases where braces are used like:
|
Yeah, I think it should be consistent. Either align assignments or not but don't change the behavior. I've done plenty of compiler work in my days and I could give this a shot. |
I have now switched it so the bitsets get aligned. |
Incorrect
Now without
Flags = {.SHADER_VISIBLE},
The consecutive assignments inside the initializer are no longer aligned.
The text was updated successfully, but these errors were encountered: