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

pbjs generates wrong code by replacing 'w' with 'writer' #663

Closed
flumpt opened this Issue Jan 27, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@flumpt

flumpt commented Jan 27, 2017

protobuf.js version: 6.6.1

I have the following ProtoBuf message:

message Quaternion {
  float x = 1;
  float y = 2;
  float z = 3;
  float w = 4;
}

If i use on this message

pbjs -t static-module -w commonjs

the generated class has a property 'w', but all methods replaced the 'w' with 'writer' as you can see in the following example:

Quaternion.encode = function encode(message, writer) {
    if (!writer)
        writer = $Writer.create();
    if (message.x !== undefined && message.hasOwnProperty("x"))
        writer.uint32(/* id 1, wireType 5 =*/13).float(message.x);
    if (message.y !== undefined && message.hasOwnProperty("y"))
        writer.uint32(/* id 2, wireType 5 =*/21).float(message.y);
    if (message.z !== undefined && message.hasOwnProperty("z"))
        writer.uint32(/* id 3, wireType 5 =*/29).float(message.z);
    if (message.writer !== undefined && message.hasOwnProperty("writer"))
        writer.uint32(/* id 4, wireType 5 =*/37).float(message.writer);
    return writer;
};

dcodeIO added a commit that referenced this issue Jan 27, 2017

@dcodeIO dcodeIO added the bug label Jan 27, 2017

@dcodeIO

This comment has been minimized.

Owner

dcodeIO commented Jan 27, 2017

Feel free to reopen if there are still any issues!

@dcodeIO dcodeIO closed this Jan 27, 2017

@flumpt

This comment has been minimized.

flumpt commented Jan 30, 2017

Thank you for the quick fix. Works like a charm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment