protobuf-javascript icon indicating copy to clipboard operation
protobuf-javascript copied to clipboard

toObject method of my message class uses an undeclared variable

Open sakekasi opened this issue 6 years ago • 2 comments

What version of protobuf and what language are you using? Version: 3.7.0 Language: Javascript

What operating system (Linux, Windows, ...) and version?

Ubuntu 16.04.5 LTS (Bitnami LAMP) MacOS Mojave 10.14.2

What runtime / compiler are you using (e.g., python version or gcc version) node js v11.10.1

What did you do? Steps to reproduce the behavior: file minimal.proto:

syntax = "proto3";

message M1 {
  uint64 x = 1;
}

message M2 {
  M1 m = 1;
}

run protoc --js_out="import_style=commonjs,binary:." minimal.proto What did you expect to see

proto.M2.toObject = function(includeInstance, msg) {
  var obj, f = {
    m: (f = msg.getM()) && proto.M1.toObject(includeInstance, f)
  };

  if (includeInstance) {
    obj.$jspbMessageInstance = msg;
  }
  return obj;
};

(or at least that's what it was doing when it worked with version 3.5)

What did you see instead?

proto.M2.toObject = function(includeInstance, msg) {
  var obj = {
    m: (f = msg.getM()) && proto.M1.toObject(includeInstance, f)
  };

  if (includeInstance) {
    obj.$jspbMessageInstance = msg;
  }
  return obj;
};

note that the declaration of f is missing in this code

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment

sakekasi avatar Mar 14 '19 07:03 sakekasi

Any update on progress with this? Had to downgrade to 3.5 to make it work

sakekasi avatar May 28 '19 19:05 sakekasi

This was fixed internally in cl/405686382. We should port it to open source.

dibenede avatar Sep 23 '22 22:09 dibenede