[Bug]: Confusion on field annotation for inherited models (protobuf)
Describe the bug
The annotation of fields for inherited models targeting a protobuf emitter is a bit confusing.
import "@typespec/protobuf";
using TypeSpec.Protobuf;
@package({
name: "test",
})
namespace test;
model Parent {
id: int64
}
model Child1 is Parent {} // Not working
@@field(Child1.id, 1);
model Child2 extends Parent {} // Outputs empty `message`
@@field(Child2.id, 1);
model Child3 { // Correct
...Parent
}
@@field(Child3.id, 1);
I couldn't figure out from the documentation why only Child3 would yield the correct result. From what I've tested, it seems that for Child1 and Child2 there is a failure to recognize and tag the id field appropriately.
This is especially confusing since I'm using this for generating openapi3 specs (through @typespec/http) as well, with syntax of Child1 working as expected.
Any insights as to whether this is a bug or just a misunderstanding of the language would be appreciated thanks !
Reproduction
https://typespec.io/playground?options=%7B%22linterRuleSet%22%3A%7B%22extends%22%3A%5B%22%40typespec%2Fhttp%2Fall%22%5D%7D%7D&c=aW1wb3J0ICJAdHlwZXNwZWMvcHJvdG9idWYiOwoKdXNpbmcgVHlwZVNwZWMuUMcbOwoKQHBhY2thZ2UoewogIG5hbWU6ICJ0ZXN0IiwKfSkKxBFzcGFjZSDEFDsKCm1vZGVsIFBhcmVudCB7CglpZDogaW50NjQKfcgdQ2hpbGQxIGlzySd9CkBAZmllbGQoxhwuaWQsIDEpyU%2FFFjIgZXh0ZW5k2Tcy1Tcz5ACGLi4uxjUKzzQzyDQ%3D&e=%40typespec%2Fprotobuf
Checklist
- [X] Follow our Code of Conduct
- [X] Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion.
- [X] The provided reproduction is a minimal reproducible example of the bug.