Skip to content

Commit

Permalink
Fix prefixing of built-in literals
Browse files Browse the repository at this point in the history
Ref. #388
  • Loading branch information
treiher committed Aug 10, 2020
1 parent b44d02f commit acc6fa0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion rflx/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ def prefixed_expression(expression: Expr) -> Expr:
**{
v: v.__class__(f"{self.package}.{v.name}")
for v in expression.variables()
if v.identifier in literals
if v.identifier in literals and v.identifier not in BUILTIN_LITERALS
},
}
).simplified()
Expand Down Expand Up @@ -2162,6 +2162,8 @@ def qualified_type_name(name: ID, package: ID) -> ID:
BOOLEAN.identifier: BOOLEAN,
}

BUILTIN_LITERALS = {l for t in BUILTIN_TYPES.values() for l in t.literals}


def is_internal_type(name: StrID) -> bool:
return ID(name) in INTERNAL_TYPES or any(
Expand Down
8 changes: 4 additions & 4 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1086,13 +1086,13 @@ def test_prefixed_message() -> None:
GreaterEqual(Variable("F1"), Number(200)),
first=First("F1"),
),
Link(Field("F2"), FINAL),
Link(Field("F2"), FINAL, Equal(Variable("F2"), Variable("True"))),
Link(Field("F3"), Field("F4"), length=Variable("F3")),
Link(Field("F4"), FINAL),
],
{
Field("F1"): deepcopy(MODULAR_INTEGER),
Field("F2"): deepcopy(MODULAR_INTEGER),
Field("F2"): deepcopy(BOOLEAN),
Field("F3"): deepcopy(RANGE_INTEGER),
Field("F4"): Opaque(),
},
Expand All @@ -1113,13 +1113,13 @@ def test_prefixed_message() -> None:
GreaterEqual(Variable("X_F1"), Number(200)),
first=First("X_F1"),
),
Link(Field("X_F2"), FINAL),
Link(Field("X_F2"), FINAL, Equal(Variable("X_F2"), Variable("True"))),
Link(Field("X_F3"), Field("X_F4"), length=Variable("X_F3")),
Link(Field("X_F4"), FINAL),
],
{
Field("X_F1"): deepcopy(MODULAR_INTEGER),
Field("X_F2"): deepcopy(MODULAR_INTEGER),
Field("X_F2"): deepcopy(BOOLEAN),
Field("X_F3"): deepcopy(RANGE_INTEGER),
Field("X_F4"): Opaque(),
},
Expand Down

0 comments on commit acc6fa0

Please sign in to comment.