From f8f7d8312773a852c6d6d91f99d8147add131d55 Mon Sep 17 00:00:00 2001 From: whitequark Date: Sat, 9 Nov 2019 16:44:01 +0000 Subject: [PATCH] hdl.rec: fix Record.like() being called through a subclass. The subclass does not necessarily take layout as the first argument. --- nmigen/hdl/rec.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nmigen/hdl/rec.py b/nmigen/hdl/rec.py index 58e1e85..115fe17 100644 --- a/nmigen/hdl/rec.py +++ b/nmigen/hdl/rec.py @@ -83,8 +83,8 @@ class Layout: # 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: @@ -107,7 +107,7 @@ class Record(Value): 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: -- 2.30.2