Skip to content
This repository has been archived by the owner on May 27, 2022. It is now read-only.

Unable to compile protos with nested messages of the same name #24

Open
schmichael opened this issue Mar 14, 2013 · 0 comments
Open

Unable to compile protos with nested messages of the same name #24

schmichael opened this issue Mar 14, 2013 · 0 comments

Comments

@schmichael
Copy link
Contributor

Google's protoc can compile the following just fine as the duplicate message Xs are in different enclosing messages:

message A {
    optional B b = 1;
    optional C c = 2;

    message B {
        optional X x = 1;
        message X {
            optional bool wat = 1;
        }
    }
    message C {
        optional X x = 1;
        message X {
            optional bool wat = 1;
        }
    }
}

palm 0.1.2 produces the following:

p.proto...                                                            [FAIL]
Traceback (most recent call last):
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/palm/palmc/main.py", line 24, in run
    r = parser.parse(source)
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/baseparser.py", line 32, in parse
    return processor( value, data )
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/dispatchprocessor.py", line 32, in __call__
    result = dispatchList( self, tags, buffer )
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/dispatchprocessor.py", line 59, in dispatchList
    return map( dispatch, [source]*len(taglist), taglist, [buffer]*len(taglist))
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/dispatchprocessor.py", line 54, in dispatch
    return function( tag, buffer )
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/palm/palmc/parse.py", line 63, in message
    dispatchList(self, subtags, buffer)
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/dispatchprocessor.py", line 59, in dispatchList
    return map( dispatch, [source]*len(taglist), taglist, [buffer]*len(taglist))
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/dispatchprocessor.py", line 54, in dispatch
    return function( tag, buffer )
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/palm/palmc/parse.py", line 88, in message_body
    return dispatchList(self, subtags, buffer)
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/dispatchprocessor.py", line 59, in dispatchList
    return map( dispatch, [source]*len(taglist), taglist, [buffer]*len(taglist))
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/dispatchprocessor.py", line 54, in dispatch
    return function( tag, buffer )
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/palm/palmc/parse.py", line 63, in message
    dispatchList(self, subtags, buffer)
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/dispatchprocessor.py", line 59, in dispatchList
    return map( dispatch, [source]*len(taglist), taglist, [buffer]*len(taglist))
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/dispatchprocessor.py", line 54, in dispatch
    return function( tag, buffer )
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/palm/palmc/parse.py", line 88, in message_body
    return dispatchList(self, subtags, buffer)
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/dispatchprocessor.py", line 59, in dispatchList
    return map( dispatch, [source]*len(taglist), taglist, [buffer]*len(taglist))
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/dispatchprocessor.py", line 54, in dispatch
    return function( tag, buffer )
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/palm/palmc/parse.py", line 63, in message
    dispatchList(self, subtags, buffer)
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/dispatchprocessor.py", line 59, in dispatchList
    return map( dispatch, [source]*len(taglist), taglist, [buffer]*len(taglist))
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/dispatchprocessor.py", line 54, in dispatch
    return function( tag, buffer )
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/palm/palmc/parse.py", line 83, in message_label
    raise ProtoParseError(start, stop, buffer, "message %s already defined" % self.current_message)
ProtoParseError: [line 1] message 2-X already defined

palm 0.1.5 produces the following:

p.proto...                                                            [FAIL]
Traceback (most recent call last):
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/palm/palmc/main.py", line 36, in run
    r = parser.parse(source)
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/baseparser.py", line 32, in parse
    return processor( value, data )
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/dispatchprocessor.py", line 32, in __call__
    result = dispatchList( self, tags, buffer )
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/dispatchprocessor.py", line 59, in dispatchList
    return map( dispatch, [source]*len(taglist), taglist, [buffer]*len(taglist))
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/dispatchprocessor.py", line 54, in dispatch
    return function( tag, buffer )
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/palm/palmc/parse.py", line 81, in message
    dispatchList(self, subtags, buffer)
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/dispatchprocessor.py", line 59, in dispatchList
    return map( dispatch, [source]*len(taglist), taglist, [buffer]*len(taglist))
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/dispatchprocessor.py", line 54, in dispatch
    return function( tag, buffer )
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/palm/palmc/parse.py", line 106, in message_body
    return dispatchList(self, subtags, buffer)
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/dispatchprocessor.py", line 59, in dispatchList
    return map( dispatch, [source]*len(taglist), taglist, [buffer]*len(taglist))
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/dispatchprocessor.py", line 54, in dispatch
    return function( tag, buffer )
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/palm/palmc/parse.py", line 81, in message
    dispatchList(self, subtags, buffer)
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/dispatchprocessor.py", line 59, in dispatchList
    return map( dispatch, [source]*len(taglist), taglist, [buffer]*len(taglist))
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/dispatchprocessor.py", line 54, in dispatch
    return function( tag, buffer )
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/palm/palmc/parse.py", line 106, in message_body
    return dispatchList(self, subtags, buffer)
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/dispatchprocessor.py", line 59, in dispatchList
    return map( dispatch, [source]*len(taglist), taglist, [buffer]*len(taglist))
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/dispatchprocessor.py", line 54, in dispatch
    return function( tag, buffer )
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/palm/palmc/parse.py", line 81, in message
    dispatchList(self, subtags, buffer)
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/dispatchprocessor.py", line 59, in dispatchList
    return map( dispatch, [source]*len(taglist), taglist, [buffer]*len(taglist))
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/simpleparse/dispatchprocessor.py", line 54, in dispatch
    return function( tag, buffer )
  File "/home/schmichael/src/ua/pyreactor-client/lib/python2.6/site-packages/palm/palmc/parse.py", line 101, in message_label
    raise ProtoParseError(start, stop, buffer, "message %s already defined" % self.current_message)
ProtoParseError: [line 1] message 2-X already defined
schmichael added a commit to schmichael/palm that referenced this issue Mar 14, 2013
Messages were named using their stack *depth* so 2 messages of the same
depth collided. This attempt names messages by their full scope -
avoiding collisions while hopefully not breaking other stuffs.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant