Skip to content

Commit

Permalink
hdl.rec: fix Record.like() being called through a subclass.
Browse files Browse the repository at this point in the history
The subclass does not necessarily take layout as the first argument.
  • Loading branch information
whitequark committed Nov 9, 2019
1 parent dc2a09b commit f8f7d83
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions nmigen/hdl/rec.py
Expand Up @@ -83,8 +83,8 @@ def __eq__(self, other):

# Unlike most Values, Record *can* be subclassed.
class Record(Value):
@classmethod
def like(cls, other, *, name=None, name_suffix=None, src_loc_at=0):
@staticmethod
def like(other, *, name=None, name_suffix=None, src_loc_at=0):
if name is not None:
new_name = str(name)
elif name_suffix is not None:
Expand All @@ -107,7 +107,7 @@ def concat(a, b):
fields[field_name] = Signal.like(field, name=concat(new_name, field_name),
src_loc_at=1 + src_loc_at)

return cls(other.layout, name=new_name, fields=fields, src_loc_at=1)
return Record(other.layout, name=new_name, fields=fields, src_loc_at=1)

def __init__(self, layout, *, name=None, fields=None, src_loc_at=0):
if name is None:
Expand Down

0 comments on commit f8f7d83

Please sign in to comment.