Giter VIP home page Giter VIP logo

Comments (2)

jhump avatar jhump commented on July 27, 2024

Your code example at the bottom does not match the example schema at the top. The reason you are running into errors is because your code example uses lower-case for both -- a message named "a" and a field named "a". But the schema at the top has the message types capitalized -- so a message named "A" and a field named "a". If you change the case of the message, it should work.

-a := builder.NewMessage("a")
+a := builder.NewMessage("A")
 builder.AddNestedMessage(a)
 builder.AddField(builder.NewField("a"), builder.FieldTypeMessage(a))

It is simply not allowed to have conflicting names in the same scope. So we will not make any changes to try to support both being named "a". You'll find that compilers like protoc and buf also complain if you tried to actually write a proto source file like that, because it is not a valid Protobuf schema.

// test.proto
syntax = "proto3";
message Message {
   message a {
   }
   a a = 1;
}
$ buf build
test.proto:6:6:symbol "Message.a" already defined at test.proto:4:12

$ protoc test.proto -o /dev/null
test.proto:4:12: "a" is already defined in "Message".
test.proto:6:4: "a" is not defined.

from protoreflect.

tanner-bruce avatar tanner-bruce commented on July 27, 2024

Well, that'd do it. Appreciate the quick response!

from protoreflect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.