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

Enums are not handled in the proto compiler #34

Closed
evanw opened this issue Apr 13, 2016 · 1 comment · Fixed by #41
Closed

Enums are not handled in the proto compiler #34

evanw opened this issue Apr 13, 2016 · 1 comment · Fixed by #41
Assignees
Labels

Comments

@evanw
Copy link

evanw commented Apr 13, 2016

Maybe I'm missing something, but I can't get enums to work:

$ cat > example.proto
package figma;

enum ExampleType {
  A = 0;
  B = 1;
}

message Example {
  required ExampleType type = 1;
}
$ ./bin/pbf example.proto > example.js
$ node -e 'pbf = require("./index"), console.log(require("./example").Example.write({type: "A"}, new pbf()))'
pbf/example.js:16
    if (example.type !== undefined) pbf.writeMessage(1, writeExampleType, exam
                                                        ^
ReferenceError: writeExampleType is not defined
    at Object.writeExample [as write] (pbf/example.js:16:57)
    at [eval]:1:68
    at Object.exports.runInThisContext (vm.js:74:17)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:460:26)
    at evalScript (node.js:431:25)
    at startup (node.js:90:7)
    at node.js:814:3

It looks like there's code that should be handling enums, it's just never being called.

@mourner mourner added the bug label May 26, 2016
@mourner mourner changed the title Enums seem totally busted Enums are not handled in the proto to code generator May 26, 2016
@mourner mourner changed the title Enums are not handled in the proto to code generator Enums are not handled in the proto compiler May 26, 2016
@mourner
Copy link
Member

mourner commented May 27, 2016

Ha, turns out it handles enums properly if they're nested inside a message, but not when they're defined in the root. Looking into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants