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

Parsing enums with complex options should work. #787

Open
eventualbuddha opened this issue May 7, 2017 · 1 comment
Open

Parsing enums with complex options should work. #787

eventualbuddha opened this issue May 7, 2017 · 1 comment
Labels

Comments

@eventualbuddha
Copy link
Contributor

protobuf.js version: 6.7.3

Parsing enums with complex options should work. Currently it simply crashes when it gets into the RHS of the option, though not immediately. This is a sanitized version of a real proto used at my company, which seems to work fine with the Google protobuf tools but fails to parse with protobuf.js. I don't know protos that well so I am not exactly sure what the problem is.

This is part of a version 2 syntax file. The Protocol Buffer syntax definition for enums seems to indicate that the RHS of an option should be a constant. I don't know whether this qualifies, but like I said it works fine in our infrastructure.

enum AnEnum {
  LEGACY = 1 [
    (some.custom.option) = {
      type: {[an.api.type]: ITEM}, // crash on this line
      type: {[an.api.type]: PAGE},
    }
  ];
}
Error: illegal value '{' (line 4)
    at illegal (node_modules/protobufjs/src/parse.js:98:16)
    at readValue (node_modules/protobufjs/src/parse.js:137:19)
    at parseOptionValue (node_modules/protobufjs/src/parse.js:562:59)
    at parseOption (node_modules/protobufjs/src/parse.js:548:9)
    at parseInlineOptions (node_modules/protobufjs/src/parse.js:578:17)
    at parseEnumValue_line (node_modules/protobufjs/src/parse.js:525:13)
    at ifBlock (node_modules/protobufjs/src/parse.js:294:17)
    at parseEnumValue (node_modules/protobufjs/src/parse.js:515:9)
    at parseEnum_block (node_modules/protobufjs/src/parse.js:501:17)
    at ifBlock (node_modules/protobufjs/src/parse.js:290:17)
@dcodeIO dcodeIO added the bug label Jun 9, 2017
@murgatroid99
Copy link
Contributor

The syntax definition for constant is defined earlier on that page, here. The value you have written there ({type: {[an.api.type]: ITEM}, type: {[an.api.type]: PAGE},}) does not appear to be a valid constant value as defined there.

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

No branches or pull requests

3 participants