nested packed enums not handled properly
See original GitHub issueI’m trying to read a pbf with a packed repeated enum field (as defined here. The compiled pbf parser seems odd for that field:
Relation.read = function (pbf, end) {
return pbf.readFields(Relation._readField, {id: 0, keys: [], vals: [], info: null, roles_sid: [], memids: [], types: 0}, end);
};
Relation._readField = function (tag, obj, pbf) {
[…]
else if (tag === 10) obj.types.push(pbf.readVarint());
};
Shouldn’t the default value for the types field be an empty array [] (instead of 0), and the data be read via something like pbf.readPackedVarint(obj.types); (instead of obj.types.push(pbf.readVarint());)?
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
namespaces for enum types - best practices - Stack Overflow
In a large project, you would not be guaranteed that two distinct enums don't both think they are called eFeelings.
Read more >Proposal: Nested enum with implicit conversion #587 - GitHub
Instead a nesting would be fine, that produces duplicate sub-enums with the same same visibility, underlying type and attributes as the ...
Read more >Nested "enum"s should not be declared static
According to the Java Language Specification-8.9: Nested enum types are implicitly static . So there's no need to declare them static explicitly.
Read more >A New Twist on SystemVerilog Enumerated Types
Not only that, but if you're trying to connect to a VHDL DUT one "Big ... If we want to use these wrapped...
Read more >Possible compiler bug related to deeply nested enums
It's not just the existence of the nested enums, but in an application using ReactiveSwift and TCA the state is copied a huge...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

The issue is here. https://github.com/mapbox/pbf/blob/master/compile.js#L270 That line should be
I have a fix and test on a fork that I forgot about. I’ll submit a PR tomorrow.
Released as 3.0.4.