Open
Description
protobuf.js version: 6.6.5
I have a proto3 file:
syntax = "proto3"; package test; message Block { string name = 1; repeated Node inputs = 2; repeated Node outputs = 3; } message Node { string id = 1; string name = 2; }
The generated js as follows when compiled using -w es6:
Block.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
if (message.name != null && message.hasOwnProperty("name"))
if (!$util.isString(message.name))
return "name: string expected";
if (message.inputs != null && message.hasOwnProperty("inputs")) {
if (!Array.isArray(message.inputs))
return "inputs: array expected";
for (let i = 0; i < message.inputs.length; ++i) {
let error = $root.test.Node.verify(message.inputs[i]);
if (error)
return "inputs." + error;
}
}
if (message.outputs != null && message.hasOwnProperty("outputs")) {
if (!Array.isArray(message.outputs))
return "outputs: array expected";
for (let i = 0; i < message.outputs.length; ++i) {
error = $root.test.Node.verify(message.outputs[i]);
if (error)
return "outputs." + error;
}
}
ReferenceError: error is not defined
at Function.verify (compiled.pb.js:75363)
I think there is a bug when declaring the error using let, i.e. scope issue. the _ let error = $root.test.Node.verify(message.inputs[i]);_ not visible in the below code block.