diff --git a/rflx/model.py b/rflx/model.py index 47148e892..948a351be 100644 --- a/rflx/model.py +++ b/rflx/model.py @@ -107,8 +107,8 @@ def __init__(self, identifier: StrID, modulus: Expr) -> None: modulus_int = int(modulus_num) - if modulus_int > 2 ** 62: # ISSUE: Componolit/RecordFlux#182 - raise ModelError(f'modulus of "{self.name}" exceeds limit (2**62)') + if modulus_int > 2 ** 57: # ISSUE: Componolit/RecordFlux#238 + raise ModelError(f'modulus of "{self.name}" exceeds limit (2**57)') if modulus_int == 0 or (modulus_int & (modulus_int - 1)) != 0: raise ModelError(f'modulus of "{self.name}" not power of two') @@ -161,8 +161,8 @@ def __init__(self, identifier: StrID, first: Expr, last: Expr, size: Expr) -> No raise ModelError(f'size of "{self.name}" contains variable') if int(last_num).bit_length() > int(size_num): raise ModelError(f'size for "{self.name}" too small') - if int(size_num) > 62: # ISSUE: Componolit/RecordFlux#182 - raise ModelError(f'size of "{self.name}" exceeds limit (2**62)') + if int(size_num) > 57: # ISSUE: Componolit/RecordFlux#238 + raise ModelError(f'size of "{self.name}" exceeds limit (2**57)') self.__first = first self.__last = last @@ -211,8 +211,8 @@ def __init__( raise ModelError(f'size of "{self.name}" contains variable') if max(map(int, literals.values())).bit_length() > int(size_num): raise ModelError(f'size for "{self.name}" too small') - if int(size_num) > 62: # ISSUE: Componolit/RecordFlux#182 - raise ModelError(f'size of "{self.name}" exceeds limit (2**62)') + if int(size_num) > 57: # ISSUE: Componolit/RecordFlux#238 + raise ModelError(f'size of "{self.name}" exceeds limit (2**57)') if len(set(literals.values())) < len(literals.values()): raise ModelError(f'"{self.name}" contains elements with same value') for l in literals: diff --git a/tests/test_model.py b/tests/test_model.py index 3f6afb66b..a06fb213b 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -148,19 +148,19 @@ def test_type_name() -> None: def test_modular_size() -> None: - assert ModularInteger("P.T", Pow(Number(2), Number(62))).size == Number(62) + assert ModularInteger("P.T", Pow(Number(2), Number(32))).size == Number(32) def test_modular_first() -> None: - mod = ModularInteger("P.T", Pow(Number(2), Number(62))) + mod = ModularInteger("P.T", Pow(Number(2), Number(32))) assert mod.first == Number(0) assert mod.first.simplified() == Number(0) def test_modular_last() -> None: - mod = ModularInteger("P.T", Pow(Number(2), Number(62))) - assert mod.last == Sub(Pow(Number(2), Number(62)), Number(1)) - assert mod.last.simplified() == Number(2 ** 62 - 1) + mod = ModularInteger("P.T", Pow(Number(2), Number(32))) + assert mod.last == Sub(Pow(Number(2), Number(32)), Number(1)) + assert mod.last.simplified() == Number(2 ** 32 - 1) def test_modular_invalid_modulus_power_of_two() -> None: @@ -174,7 +174,8 @@ def test_modular_invalid_modulus_variable() -> None: def test_modular_invalid_modulus_limit() -> None: - with pytest.raises(ModelError, match=r'^modulus of "T" exceeds limit \(2\*\*62\)$'): + # ISSUE: Componolit/RecordFlux#238 + with pytest.raises(ModelError, match=r'^modulus of "T" exceeds limit \(2\*\*57\)$'): ModularInteger("P.T", Pow(Number(2), Number(128))) @@ -216,7 +217,8 @@ def test_range_invalid_size_too_small() -> None: def test_range_invalid_size_exceeds_limit() -> None: - with pytest.raises(ModelError, match=r'^size of "T" exceeds limit \(2\*\*62\)$'): + # ISSUE: Componolit/RecordFlux#238 + with pytest.raises(ModelError, match=r'^size of "T" exceeds limit \(2\*\*57\)$'): RangeInteger("P.T", Number(0), Number(256), Number(128)) @@ -231,7 +233,8 @@ def test_enumeration_invalid_size_too_small() -> None: def test_enumeration_invalid_size_exceeds_limit() -> None: - with pytest.raises(ModelError, match=r'^size of "T" exceeds limit \(2\*\*62\)$'): + # ISSUE: Componolit/RecordFlux#238 + with pytest.raises(ModelError, match=r'^size of "T" exceeds limit \(2\*\*57\)$'): Enumeration("P.T", {"A": Number(256)}, Number(128), False) diff --git a/tests/test_parser.py b/tests/test_parser.py index 60cd3ee39..163cee259 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -412,13 +412,14 @@ def test_illegal_redefinition() -> None: def test_invalid_modular_type() -> None: + # ISSUE: Componolit/RecordFlux#238 assert_parse_exception_string( """ package Test is type T is mod 2**128; end Test; """, - r'^modulus of "T" exceeds limit \(2\*\*62\)', + r'^modulus of "T" exceeds limit \(2\*\*57\)', )