Skip to content

fix: numerous bugs found by formatting Nelm#13

Merged
ilya-lesikov merged 9 commits intomainfrom
fix/bugs
Feb 24, 2026
Merged

fix: numerous bugs found by formatting Nelm#13
ilya-lesikov merged 9 commits intomainfrom
fix/bugs

Conversation

@ilya-lesikov
Copy link
Member

No description provided.

Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
Var specs are now grouped by exportability only (blank _, exported,
unexported) and preserve their original relative order within each group.
This prevents breaking initialization dependencies where later vars
depend on earlier ones being initialized first.

Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
When extracting specs from GenDecl to merge into a single block,
doc comments (Decs.Start) and inline comments (Decs.End) on the GenDecl
were lost. transferGenDeclDecsToSpecs now transfers them to the first/last
spec before discarding the GenDecl.

Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
Transfer GenDecl.Decs.End (inline comments) to the last spec's Decs.End.
Work around DST limitation where the last spec's End comment in a
parenthesized block gets rendered after the closing paren by moving it
to Start via fixLastSpecEndComment.

Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
Free-floating comments (section headers separated from code by a blank
line) on var/const declarations now cause FormatFile to return an error
instead of silently corrupting the comment position during merge.

Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
Anonymous structs (table tests, inline struct fields, composite literal
types) are no longer reordered. reorderStructFields now targets
*dst.TypeSpec nodes containing *dst.StructType, skipping all anonymous
struct types to preserve table test readability.

Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
Structs with json, yaml, xml, toml, or protobuf struct tags now
preserve their original field order to prevent changing wire format.

Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
assembleFieldList now unconditionally resets both Decs.Before and
Decs.After for all fields, preventing stale EmptyLine decorations
from the original source from leaking through.

Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
Typed const specs (Stage, ReleaseType, etc.) now preserve their
original relative order within the same type group. Only untyped
consts are alphabetized, keeping intentional orderings intact.

Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
@ilya-lesikov ilya-lesikov merged commit 013e939 into main Feb 24, 2026
2 checks passed
@ilya-lesikov ilya-lesikov deleted the fix/bugs branch February 24, 2026 11:50
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

Successfully merging this pull request may close these issues.

1 participant