[ILibraryView / Pattern] flatten() should raise PatternError if asked to preserve ports from a repeated ref
This commit is contained in:
parent
b843ffb4d3
commit
c32168dc64
4 changed files with 36 additions and 0 deletions
|
|
@ -308,6 +308,11 @@ class ILibraryView(Mapping[str, 'Pattern'], metaclass=ABCMeta):
|
|||
continue
|
||||
|
||||
for ref in pat.refs[target]:
|
||||
if flatten_ports and ref.repetition is not None and target_pat.ports:
|
||||
raise PatternError(
|
||||
f'Cannot flatten ports from repeated ref to {target!r}; '
|
||||
'flatten with flatten_ports=False or expand/rename the ports manually first.'
|
||||
)
|
||||
p = ref.as_pattern(pattern=target_pat)
|
||||
if not flatten_ports:
|
||||
p.ports.clear()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue