-
Notifications
You must be signed in to change notification settings - Fork 329
Open
Labels
emitter:protobufThe protobuf emitterThe protobuf emitter
Description
When using the Protobuf emitter, @field(n) is mandatory.
However, when a model extends another model, field numbers are not
merged or offset. This leads to duplicated field numbers in the
generated message, which is invalid in Protobuf.
Example:
model Base {
@field(1)
id: string;
}
model Child extends Base {
@field(1)
name: string;
}
Generated proto:
message Child {
string id = 1;
string name = 1; // invalid: duplicate field number
}
This makes model inheritance unsafe with Protobuf.
Current issues:
- @field numbers are scoped per model, not per message
- No validation or error is raised
- No automatic offset or merging strategy exists
This breaks:
- Protobuf constraints
- Backward compatibility guarantees
- Design-first modeling with inheritance
Suggested directions:
- Automatically shift child field numbers after inherited fields
- Or support an implicit field numbering strategy
- Or disallow inheritance for proto models with a clear error
At the moment, using inheritance with Protobuf is dangerous and
non-deterministic.
Metadata
Metadata
Assignees
Labels
emitter:protobufThe protobuf emitterThe protobuf emitter