lib.data: allow Const as value of Layout.const(...) field.

Fixes #838.
This commit is contained in:
Catherine 2023-07-18 14:20:05 +00:00
parent 385b10d743
commit d1ca9c46a5
2 changed files with 5 additions and 1 deletions

View file

@ -238,7 +238,7 @@ class Layout(ShapeCastable, metaclass=ABCMeta):
"it casts to, {!r}, and not {!r}"
.format(field.shape, cast_field_shape,
key_value.shape()))
else:
elif not isinstance(key_value, Const):
key_value = Const(key_value, cast_field_shape)
int_value &= ~(((1 << cast_field_shape.width) - 1) << field.offset)
int_value |= key_value.value << field.offset