question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nested packed enums not handled properly

See original GitHub issue

I’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:closed
  • Created 7 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
kjvalencikcommented, Nov 13, 2016

The issue is here. https://github.com/mapbox/pbf/blob/master/compile.js#L270 That line should be

if (enumValues && !field.repeated)

I have a fix and test on a fork that I forgot about. I’ll submit a PR tomorrow.

0reactions
mournercommented, Nov 14, 2016

Released as 3.0.4.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found