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

Field with the same name as a type results in "unresolvable field type" #569

Closed
codeka opened this Issue Dec 18, 2016 · 0 comments

Comments

Projects
None yet
2 participants
@codeka

codeka commented Dec 18, 2016

protobuf.js version: v6.2.1

A field in a message with the same name as a type should be allowed (it works in Google's protocol buffer compiler and also in protobufjs versions 5 and earlier).

syntax = "proto3";

message A {
  string whatever = 1;
}

message B {
  A A = 1;
}

Compile with:

pbjs --target static *.proto

Results in:

.../node_modules/protobufjs/cli/pbjs.js:134
                    throw err;
                    ^

Error: unresolvable field type: A
    at Field.resolve (.../node_modules/protobufjs/src/field.js:248:19)
    at .../node_modules/protobufjs/cli/targets/static.js:184:15
    at Array.forEach (native)
    at buildType (.../node_modules/protobufjs/cli/targets/static.js:183:22)
    at buildNamespace (.../node_modules/protobufjs/cli/targets/static.js:96:9)
    at .../node_modules/protobufjs/cli/targets/static.js:113:13
    at Array.forEach (native)
    at buildNamespace (.../node_modules/protobufjs/cli/targets/static.js:109:20)
    at static_target (.../node_modules/protobufjs/cli/targets/static.js:28:9)
    at .../node_modules/protobufjs/cli/pbjs.js:129:9

(Note --target json works, but if you use the subsequent .json file to generate a static module it fails with the same error. I haven't tried importing the .json file directly though).

@dcodeIO dcodeIO added the bug label Dec 18, 2016

@dcodeIO dcodeIO closed this in 19e906c Dec 18, 2016

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