[PorList] Error if multiple ports are renamed to the same name

This commit is contained in:
Jan Petykiewicz 2026-03-31 22:15:48 -07:00
commit 6a7b3b2259
2 changed files with 23 additions and 0 deletions

View file

@ -331,6 +331,10 @@ class PortList(metaclass=ABCMeta):
missing = set(mapping) - set(self.ports)
if missing:
raise PortError(f'Ports to rename were not found: {missing}')
renamed_targets = [vv for vv in mapping.values() if vv is not None]
duplicate_targets = {vv for vv in renamed_targets if renamed_targets.count(vv) > 1}
if duplicate_targets:
raise PortError(f'Renamed ports would collide: {duplicate_targets}')
for kk, vv in mapping.items():
if vv is None or vv != kk: