fix: restore reader depth on duplicate key error in map structs#34
Open
paq wants to merge 1 commit intonuskey8:mainfrom
Open
fix: restore reader depth on duplicate key error in map structs#34paq wants to merge 1 commit intonuskey8:mainfrom
paq wants to merge 1 commit intonuskey8:mainfrom
Conversation
There was a problem hiding this comment.
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_derivemap deserialization codegen to use a labeled block +breakonKeyDuplicatedinstead of an earlyreturn Err(...). - Add a regression unit test asserting reader depth returns to
0after 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace
return Err(...)withbreak '__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