TemplateEngine: adding an attribute to a derived slot that already has an override fails with a false naming collision #119
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found during #118 (
84a05042). This bug was already there before #118.Once a derived (composition-slot) template has at least one override, adding a new attribute to it with
TemplateService.AddAttributeAsyncfails with a false "Naming collision" error. Additions only work before the first override. The bundle importer (#118) works around it by ordering additions before overrides, but authoring through the Central UI or management API hits it.Repro: compose a derived slot from a base, override one inherited attribute, then add a new attribute with a fresh name. You get a collision error even though the name exists nowhere.
Fix: the collision check should compare against the effective member set (inherited plus own additions), keyed by name, and not count an override row as a second definition. Add a regression test in TemplateEngine.Tests.
Fixed in
1ccd6cfe. Cause: CollisionDetector counted a derived template's own override row (same name as a parent member) as a second definition next to the parent's row, so Add{Attribute,Alarm,Script}Async failed once any override existed. The inheritance walk now carries a (type,name) shadow set so a nearer-level member shadows the same member further up (also mid-level overrides). Real collisions (composed-module) still rejected (positive control). 6 new tests in TemplateEngine.Tests fail without the fix; build 0 warnings; TemplateEngine 624, Transport 236, Transport.Integration 161, ManagementService 790, CentralUI 1540 all pass. The #118 importer ordering workaround is now unnecessary but harmless; left in place.