diff --git a/amaranth/hdl/ast.py b/amaranth/hdl/ast.py index f5a249c..a795acf 100644 --- a/amaranth/hdl/ast.py +++ b/amaranth/hdl/ast.py @@ -442,7 +442,7 @@ class Value(metaclass=ABCMeta): continue matches.append(self == pattern) if not matches: - return Const(0) + return Const(1) elif len(matches) == 1: return matches[0] else: diff --git a/docs/changes.rst b/docs/changes.rst index 38401a7..aca5daa 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -34,6 +34,7 @@ Language changes * Added: :meth:`Value.matches` and ``with m.Case():`` accept any constant-castable objects. (`RFC 4`_) * Changed: :meth:`Value.cast` casts :class:`ValueCastable` objects recursively. * Changed: :meth:`Value.cast` treats instances of classes derived from both :class:`enum.Enum` and :class:`int` (including :class:`enum.IntEnum`) as enumerations rather than integers. +* Changed: ``Value.matches()`` with an empty list of patterns returns ``Const(1)`` rather than ``Const(0)``, to match ``with m.Case():``. * Changed: :class:`Cat` accepts instances of classes derived from both :class:`enum.Enum` and :class:`int` (including :class:`enum.IntEnum`) without warning. * Deprecated: :meth:`Const.normalize`. (`RFC 5`_) * Removed: (deprecated in 0.1) casting of :class:`Shape` to and from a ``(width, signed)`` tuple. diff --git a/tests/test_hdl_ast.py b/tests/test_hdl_ast.py index 0df07ae..65a9b39 100644 --- a/tests/test_hdl_ast.py +++ b/tests/test_hdl_ast.py @@ -599,7 +599,7 @@ class OperatorTestCase(FHDLTestCase): def test_matches(self): s = Signal(4) - self.assertRepr(s.matches(), "(const 1'd0)") + self.assertRepr(s.matches(), "(const 1'd1)") self.assertRepr(s.matches(1), """ (== (sig s) (const 1'd1)) """)