Skip to content

Commit 5797643

Browse files
wanda-phiwhitequark
authored andcommitted
docs: remove leftover TODO and warning from #1003, fix matches docs.
1 parent a0c8b18 commit 5797643

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

docs/guide.rst

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -762,20 +762,14 @@ Match operator
762762

763763
The :pc:`val.matches(*patterns)` operator examines a value against a set of patterns. It evaluates to :pc:`Const(1)` if the value *matches* any of the patterns, and to :pc:`Const(0)` otherwise. What it means for a value to match a pattern depends on the type of the pattern.
764764

765-
If the pattern is a :class:`str`, it is treated as a bit mask with "don't care" bits. After removing whitespace, each character of the pattern is compared to the bit of the value in the same position as the character. If the pattern character is ``'0'`` or ``'1'``, the comparison succeeds if the bit equals ``0`` or ``1`` correspondingly. If the pattern character is ``'-'``, the comparison always succeeds. Aside from spaces and tabs, which are ignored, no other characters are accepted.
765+
If the pattern is a :class:`str`, it is treated as a bit mask with "don't care" bits. After removing whitespace, each character of the pattern is compared to the corresponding bit of the value, where the leftmost character of the pattern (with the lowest index) corresponds to the most significant bit of the value. If the pattern character is ``'0'`` or ``'1'``, the comparison succeeds if the bit equals ``0`` or ``1`` correspondingly. If the pattern character is ``'-'``, the comparison always succeeds. Aside from spaces and tabs, which are ignored, no other characters are accepted.
766766

767767
Otherwise, the pattern is :ref:`cast to a constant <lang-constcasting>` and compared to :pc:`val` using the :ref:`equality operator <lang-cmpops>`.
768768

769-
For example, given a 8-bit value :pc:`val`, :pc:`val.matches(1, '---- -01-')` is equivalent to :pc:`(val == 1) | ((val & 0b0110_0000) == 0b0100_0000)`. Note that the direction in which bits are specified for the :pc:`.match()` operator (least to most significant) is the opposite of the direction in which an integer literal is written (most to least significant). Bit patterns in this operator are treated similarly to :ref:`bit sequence operators <lang-bitops>`.
769+
For example, given a 8-bit value :pc:`val`, :pc:`val.matches(1, '---- -01-')` is equivalent to :pc:`(val == 1) | ((val & 0b0000_0110) == 0b0000_0010)`. Bit patterns in this operator are treated similarly to :ref:`bit sequence operators <lang-bitops>`.
770770

771771
The :ref:`Case <lang-switch>` control flow block accepts the same patterns, with the same meaning, as the match operator.
772772

773-
.. TODO: https://github.com/amaranth-lang/amaranth/issues/1003
774-
775-
.. warning::
776-
777-
Do not rely on the behavior of :pc:`val.matches()` with no patterns.
778-
779773

780774
.. _lang-convops:
781775

@@ -1151,12 +1145,6 @@ Within a single :pc:`Switch` block, the statements within at most one block will
11511145

11521146
If a :pc:`Default` block is present, or the patterns in the :pc:`Case` blocks cover every possible :pc:`Switch` value, then the statements within exactly one block will be active at any time, and the sequence as a whole is called a *full condition*.
11531147

1154-
.. TODO: https://github.com/amaranth-lang/amaranth/issues/1003
1155-
1156-
.. warning::
1157-
1158-
Do not rely on the behavior of a :pc:`with m.Case():` with no patterns.
1159-
11601148
.. tip::
11611149

11621150
While all Amaranth control flow syntax can be generated programmatically, the :pc:`Switch` control block is particularly easy to use in this way:

0 commit comments

Comments
 (0)