Skip to content

Commit

Permalink
Fix missing integer type conversions for function calls
Browse files Browse the repository at this point in the history
  • Loading branch information
treiher committed May 13, 2022
1 parent 3091c80 commit 9870e22
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
14 changes: 11 additions & 3 deletions rflx/generator/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -2789,8 +2789,12 @@ def _assign_to_call( # pylint: disable = too-many-locals

arguments: list[expr.Expr] = []

for i, a in enumerate(call_expr.args):
if not isinstance(a, (expr.Number, expr.Variable, expr.Selected, expr.String)) and not (
assert len(call_expr.args) == len(call_expr.argument_types)

for i, (a, t) in enumerate(zip(call_expr.args, call_expr.argument_types)):
if not isinstance(
a, (expr.Number, expr.Variable, expr.Selected, expr.Size, expr.String)
) and not (
isinstance(a, expr.Opaque)
and isinstance(a.prefix, expr.Variable)
and a.type_ == rty.OPAQUE
Expand Down Expand Up @@ -2971,7 +2975,11 @@ def _assign_to_call( # pylint: disable = too-many-locals
):
arguments.append(expr.NamedAggregate(("Known", expr.TRUE), ("Enum", a)))
else:
arguments.append(a)
arguments.append(
expr.Call(t.identifier, [a])
if isinstance(t, rty.Integer) and not a.type_.is_compatible_strong(t)
else a
)

call = [
CallStatement(
Expand Down
1 change: 1 addition & 0 deletions tests/unit/generator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2153,6 +2153,7 @@ def test_session_state_action_error(
location=Location((10, 20)),
),
],
argument_types=[rty.Integer("C")],
),
RecordFluxError,
r"Call with undefined type as function argument not yet supported",
Expand Down

0 comments on commit 9870e22

Please sign in to comment.