Skip to content

size: fix empty struct collection expressions - #452

Merged
philhofer merged 1 commit into
tinylib:masterfrom
jakezwang:fix/empty-struct-collection-size
Sep 21, 2026
Merged

philhofer merged 1 commit into
tinylib:masterfrom
jakezwang:fix/empty-struct-collection-size

Conversation

@jakezwang

Copy link
Copy Markdown
Contributor

Collections of empty structs using the default map encoding currently produce invalid Msgsize expressions such as len(z.Named) * (1 + ), causing the generator to fail formatting otherwise valid Go input. Return the encoded header size alone when a struct has no field-size terms.

The regression generates and executes code for named and anonymous empty-struct slices and fixed, zero-length, and nested arrays. It checks the size bound and byte/stream round trips.

Fixes #101.

Validation:

  • All native packages, including _generated, pass on Go 1.24.13 and pass with -race on Go 1.26.6.
  • The new generator regression passes with -race on Go 1.24.13, 1.25.13, and 1.26.6.
  • make prepare, formatting, and golangci-lint 2.9.0 pass.

Local validation ran on macOS arm64. TinyGo was unavailable, so tinygotest was not run. The available lint version was 2.9.0 rather than CI's pinned 2.5.0.

@klauspost klauspost left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@philhofer
philhofer merged commit 540a227 into tinylib:master Sep 21, 2026
4 checks passed
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.

msgp generated code fails to compile: slice of empty struct

3 participants