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

static: build failure via webpack (Module build failed: Duplicate declaration "key") #726

Closed
tamird opened this issue Mar 24, 2017 · 1 comment

Comments

@tamird
Copy link

tamird commented Mar 24, 2017

protobuf.js version: 8401a47

ERROR in ./src/js/protos.js
Module build failed: Duplicate declaration "key"

  26927 |                         if (message.delta === $util.emptyObject)
  26928 |                             message.delta = {};
> 26929 |                         let key = reader.string();
        |                             ^
  26930 |                         reader.pos++;
  26931 |                         message.delta[typeof key === "object" ? $util.longToHash(key) : key] = $root.cockroach.gossip.Info.decode(reader, reader.uint32());
  26932 |                         break;

The full function is:

            Request.decode = function decode(reader, length) {
                if (!(reader instanceof $Reader))
                    reader = $Reader.create(reader);
                let end = length === undefined ? reader.len : reader.pos + length, message = new $root.cockroach.gossip.Request();
                while (reader.pos < end) {
                    let tag = reader.uint32();
                    switch (tag >>> 3) {
                    case 1:
                        message.node_id = reader.int32();
                        break;
                    case 2:
                        message.addr = $root.cockroach.util.UnresolvedAddr.decode(reader, reader.uint32());
                        break;
                    case 3:
                        reader.skip().pos++;
                        if (message.high_water_stamps === $util.emptyObject)
                            message.high_water_stamps = {};
                        let key = reader.int32();
                        reader.pos++;
                        message.high_water_stamps[typeof key === "object" ? $util.longToHash(key) : key] = reader.int64();
                        break;
                    case 4:
                        reader.skip().pos++;
                        if (message.delta === $util.emptyObject)
                            message.delta = {};
                        let key = reader.string();
                        reader.pos++;
                        message.delta[typeof key === "object" ? $util.longToHash(key) : key] = $root.cockroach.gossip.Info.decode(reader, reader.uint32());
                        break;
                    default:
                        reader.skipType(tag & 7);
                        break;
                    }
                }
                return message;
            };

According to http://stackoverflow.com/questions/35746371/error-duplicate-const-declaration-in-switch-case-statement, each case should be wrapped in a block to avoid the declaration leaking out.

@tamird
Copy link
Author

tamird commented Mar 24, 2017

Fixed in 8d99815.

@tamird tamird closed this as completed Mar 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant