Closed whitequark closed 1 year ago
We can fix this easily for values whose Python type is shape-castable (this is entirely within defined protocol), but there's no way to go from a View
instance to its Layout
besides Layout.of
. Just like RFC 8 and RFC 15 themselves replaced special-casing in lib.data
with a general protocol, we'll likely need to add a protocol to replace Layout.of
in a general way, such that Signal.like
can call new_function_to_extract_shape_castable_from_value(other)(Signal(other.as_value())
.
It turns out that this is a problem for more than just Signal.like
; it is also a problem for the use of Layout.of
with non-View
classes. Example:
from amaranth import *
from amaranth.lib import data
class A(data.Struct):
a : unsigned(1)
layout = data.Layout.of(Signal(A))
print(layout.members) # AttributeError: type object 'c' has no attribute 'members'
I'm bumping this to 0.4, we clearly need to address this before the release.
This should be fixed by RFC 22.
Consider: