diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-03-28 10:54:08 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-03-28 11:39:56 -0600 |
commit | d67db573786da4780653e72879033b9e24e83e28 (patch) | |
tree | 73e8ce31c3ebf605ae56ea16c6ccbd91d0c52227 | |
parent | 703c99776fdfcf0e6bd5edda572de644eba3a452 (diff) |
lib9p: idl: Allow Numbers to have ,val= or ,max=
-rw-r--r-- | lib9p/idl/__init__.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib9p/idl/__init__.py b/lib9p/idl/__init__.py index f8e1a38..6fa26b4 100644 --- a/lib9p/idl/__init__.py +++ b/lib9p/idl/__init__.py @@ -414,15 +414,25 @@ def parse_members(ver: str, env: dict[str, Type], struct: Struct, specs: str) -> _ = member.max_cnt # force validation if maxstr := m.group("max"): - if (not isinstance(member.typ, Primitive)) or member.cnt: - raise ValueError("',max=' may only be specified on a non-repeated atom") + if ( + not isinstance(member.typ, Primitive) + and not isinstance(member.typ, Number) + ) or member.cnt: + raise ValueError( + "',max=' may only be specified on a non-repeated numeric type" + ) member.max = parse_expr(maxstr) else: member.max = Expr() if valstr := m.group("val"): - if (not isinstance(member.typ, Primitive)) or member.cnt: - raise ValueError("',val=' may only be specified on a non-repeated atom") + if ( + not isinstance(member.typ, Primitive) + and not isinstance(member.typ, Number) + ) or member.cnt: + raise ValueError( + "',val=' may only be specified on a non-repeated numeric type" + ) member.val = parse_expr(valstr) else: member.val = Expr() |