-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Description
protobuf.js version:
→ npm version
{
protobufjs: '6.8.8',
npm: '6.12.0',
ares: '1.15.0',
brotli: '1.0.7',
cldr: '35.1',
http_parser: '2.8.0',
icu: '64.2',
llhttp: '1.1.1',
modules: '72',
napi: '4',
nghttp2: '1.38.0',
node: '12.1.0',
openssl: '1.1.1b',
tz: '2019a',
unicode: '12.1',
uv: '1.28.0',
v8: '7.4.288.21-node.16',
zlib: '1.2.11'
}
For this proto file containing extraneous semicolons:
syntax="proto3";
message Foo {
int32 x = 1;; // <-- two semicolons
}
The official protoc
(v3.7.1) compiler will correctly parse and ferry the descriptors to a plugin:
→ protoc --js_out=`mktemp -d` foo.proto
→ echo $?
0
However, pbjs
's parser chokes on the extra semicolon:
→ pbjs foo.proto
/usr/local/lib/node_modules/protobufjs/cli/pbjs.js:245
throw err;
^
Error: illegal token ';' (foo.proto, line 4)
at illegal (/usr/local/lib/node_modules/protobufjs/src/parse.js:94:16)
at parseType_block (/usr/local/lib/node_modules/protobufjs/src/parse.js:335:31)
at ifBlock (/usr/local/lib/node_modules/protobufjs/src/parse.js:286:17)
at parseType (/usr/local/lib/node_modules/protobufjs/src/parse.js:304:9)
at parseCommon (/usr/local/lib/node_modules/protobufjs/src/parse.js:259:17)
at parse (/usr/local/lib/node_modules/protobufjs/src/parse.js:728:21)
at process (/usr/local/lib/node_modules/protobufjs/src/root.js:107:30)
at fetch (/usr/local/lib/node_modules/protobufjs/src/root.js:166:13)
at Root.load (/usr/local/lib/node_modules/protobufjs/src/root.js:194:13)
at Root.loadSync (/usr/local/lib/node_modules/protobufjs/src/root.js:235:17)
This isn't limited to trailing semicolons on fields either, but pretty much anywhere it's legal to put a "statement"; see emptyStatement
from the proto grammar. I've got a patch ready with a light-touch fix that covers this case as well as many others (PR incoming after this issue is posted, didn't want them coupled).
technotronic12, josephharrington and mjameswh
Metadata
Metadata
Assignees
Labels
No labels