Skip to content

Commit

Permalink
fix: scope variable for map field to avoid redeclaration (#1717) (#1718)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander Fenster <fenster@google.com>
  • Loading branch information
steinybot and alexander-fenster authored Jul 7, 2022
1 parent a1d6029 commit 1d3c02a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function decoder(mtype) {
var field = mtype._fieldsArray[i].resolve(),
type = field.resolvedType instanceof Enum ? "int32" : field.type,
ref = "m" + util.safeProp(field.name); gen
("case %i:", field.id);
("case %i: {", field.id);

// Map fields
if (field.map) { gen
Expand Down Expand Up @@ -104,8 +104,9 @@ function decoder(mtype) {
else gen
("%s=r.%s()", ref, type);
gen
("break");
// Unknown fields
("break")
("}");
// Unknown fields
} gen
("default:")
("r.skipType(t&7)")
Expand Down

0 comments on commit 1d3c02a

Please sign in to comment.