[ILibraryView / Pattern] flatten() shouldn't drop ports-only patterns if flatten_ports=True

This commit is contained in:
Jan Petykiewicz 2026-03-30 21:11:00 -07:00
commit b843ffb4d3
4 changed files with 38 additions and 3 deletions

View file

@ -303,7 +303,8 @@ class ILibraryView(Mapping[str, 'Pattern'], metaclass=ABCMeta):
target_pat = flattened[target]
if target_pat is None:
raise PatternError(f'Circular reference in {name} to {target}')
if target_pat.is_empty(): # avoid some extra allocations
ports_only = flatten_ports and bool(target_pat.ports)
if target_pat.is_empty() and not ports_only: # avoid some extra allocations
continue
for ref in pat.refs[target]: