Closed g-berthiaume closed 3 years ago
@g-berthiaume
Hi ~
Yeah, there is a name collision mistake.
type
is a keyword like what the keyword typedef
does in C. Example here
Use like:
type Timestamp = int64;
it will fix:
proto mytest
enum payload_data_type_e: uint8 {
PAYLOAD_DATA_TYPE_UNKNOWN = 1
PAYLOAD_DATA_TYPE_DETECTOR = 2
}
message payload_data_t {
payload_data_type_e data = 1
}
@g-berthiaume
hmm, yep. the word type
is a reserved keyword, this breaks parsing, it can't be used as a message field's name.
But I think this word "type" is a very common word, so I decided to solve this.
A newer version of bitproto, v0.4.2 was just uploaded, which fixed this problem.
Now the following message parses well:
message Test {
uint4 type = 1 // it's ok now
}
You can upgrade bitproto via pip install -U bitproto
.
Interesting ! As I'm starting to work on a basic compiler, I can appreciate the complexity of those kinds of bugs. Thanks for your work!
On another note:
For some reason, I'm having difficulty updating: Pip raise the following exception:
FileNotFoundError: [Errno 2] No such file or directory: '../README.rst'
Is it possible that the package builder executes setup.py
outside of the compiler/
directory?
Maybe it's a problem with my machine ^^
@g-berthiaume Thanks for reporting this bug.
pip install -U bitproto
would work now.
Or you can download the binary directly from https://github.com/hit9/bitproto/releases/tag/v0.4.4
I think the parser will fail if the message name is contained in the message field type.
Steps to reproduce Using the following schema:
When compiling
My guess is that this error is due to a kind of name collision in the lexer.