Skip to content

fix: restore reader depth on duplicate key error in map structs#34

Open
paq wants to merge 1 commit intonuskey8:mainfrom
paq:fix-32
Open

fix: restore reader depth on duplicate key error in map structs#34
paq wants to merge 1 commit intonuskey8:mainfrom
paq:fix-32

Conversation

@paq
Copy link
Copy Markdown
Contributor

@paq paq commented Apr 11, 2026

Replace return Err(...) with break '__zerompk_read_map Err(...) for duplicate key errors in derived map struct deserialization, so that the reader depth is properly restored via the normal exit path instead of bypassing it with an early return. Fix #32

Copilot AI review requested due to automatic review settings April 11, 2026 23:54
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes an error-path control-flow issue in FromMessagePack derive output for #[msgpack(map)] structs / enum variants so duplicate-key detection no longer bypasses the normal exit path (and the reader depth is restored correctly).

Changes:

  • Update zerompk_derive map deserialization codegen to use a labeled block + break on KeyDuplicated instead of an early return Err(...).
  • Add a regression unit test asserting reader depth returns to 0 after a duplicate-key error.
  • Add a cfg(test) self-crate alias to make ::zerompk::... paths resolve in in-crate derive tests.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
zerompk_derive/src/lib.rs Adjusts generated map-struct / map-variant read logic to avoid early-return on duplicate keys and return via the normal result path.
zerompk/src/read.rs Adds a unit test that reproduces the duplicate-key scenario and asserts reader.depth is restored.
zerompk/src/lib.rs Adds extern crate self as zerompk; under cfg(test) so derive output using ::zerompk compiles in unit tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

FromMessagePack derive: early return Err in map arms skips decrement_depth()

2 participants