Skip to content

Commit d660bfc

Browse files
committed
RFC #73: Add checks to lib.enum too.
1 parent d195662 commit d660bfc

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

text/0073-stricter-connections.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,24 @@ This results in a `ValueCastable`'s `.eq()` not being called, and thereby bypass
4747

4848
This RFC proposes removing the `Value.cast()` so a `ValueCastable`'s `.eq()` will be called directly.
4949

50+
This RFC proposes updating `lib.enum.EnumView` in the same manner, for the same reason, as `lib.data.View`.
51+
5052
## Reference-level explanation
5153
[reference-level-explanation]: #reference-level-explanation
5254

55+
Modify `lib.wiring.connect()` to not pass port members through `Value.cast()`, so that a `ValueCastable`'s `.eq()` will be called, allowing it to perform compatibility checks.
56+
- If a `ValueCastable` doesn't define `.eq()`, reject the assignment.
57+
5358
Modify `lib.data.View.eq(other)` to add the following checks:
5459
- If `other` is a `ValueCastable`, do `Layout.cast(other.shape())`
5560
- If a valid `Layout` is returned, reject the assignment if it doesn't match `self.shape()`.
5661
- If `Layout.cast()` raises, reject the assignment.
5762
- Otherwise, proceed as normal.
5863

59-
Modify `lib.wiring.connect()` to not pass port members through `Value.cast()`, so that a `ValueCastable`'s `.eq()` will be called, allowing it to perform compatibility checks.
60-
- If a `ValueCastable` doesn't define `.eq()`, reject the assignment.
64+
Modify `lib.enum.EnumView.eq(other)` to add the following checks:
65+
- If `other` is an `EnumView`, reject the assignment if enum types are not identical.
66+
- Otherwise, if `other` is another `ValueCastable`, reject the assignment.
67+
- Otherwise, proceed as normal.
6168

6269
Rejected assignments are a warning in Amaranth 0.6 and becomes a hard error in Amaranth 0.7.
6370

0 commit comments

Comments
 (0)