Skip to content
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

Make msgp:sort directive more predictable when dealing with imports #27

Open
iansuvak opened this issue Aug 15, 2023 · 0 comments
Open
Labels
Team Carbon-11 Work belongs to Carbon-11

Comments

@iansuvak
Copy link
Contributor

Current implementation of msgp:sort directive used for canonical encoding and decoding by sorting map fields associate the types string names with it's SortType and LessFunction. This is done as commented in elem.go since map keys don't have references to the Elem associated with the directive.

Additionally msgp parses all import packages for the package it's generating methods which means that a msgp:sort directive exists for a given type already in the imported package it will be written first and then later overwritten by the main package being parsed which is always parsed last.

This can lead to interesting sorts of bugs where a msgp:sort can be missing in the parsed package but still be populated with potentially unexpected values from one of the imports.

We should guard against this either by not using sort directives from the import packages or by finding a way to make the process more robust and stop attaching the directives to strings representing type names.

@iansuvak iansuvak added the Team Carbon-11 Work belongs to Carbon-11 label Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team Carbon-11 Work belongs to Carbon-11
Projects
None yet
Development

No branches or pull requests

1 participant