algorand / algorand/msgp

Make msgp:sort directive more predictable when dealing with imports

未关闭
#27 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
Team Carbon-11
主要语言
Go
星标
12
派生
18
PR 合并指标
30 天内没有已合并 PR

描述

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.

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。