Skip to content

Commit

Permalink
Merge pull request #162 from JoeffreyLegaux/bug_member_inlining
Browse files Browse the repository at this point in the history
bugfix : symbols from the inlined member's dummies were hoisted in the calling routine
  • Loading branch information
reuterbal authored Oct 10, 2023
2 parents 0e83ac4 + 14c149c commit d89e2ee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion loki/transform/transform_inline.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def _map_unbound_dims(var, val):

# Get local variable declarations and hoist them
decls = FindNodes(VariableDeclaration).visit(member.spec)
decls = tuple(d for d in decls if all(s.name.lower() not in routine._dummies for s in d.symbols))
decls = tuple(d for d in decls if all(s.name.lower() not in member._dummies for s in d.symbols))
decls = tuple(d for d in decls if all(s not in routine.variables for s in d.symbols))
routine.spec.append(decls)

Expand Down
3 changes: 3 additions & 0 deletions tests/test_transform_inline.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,9 @@ def test_inline_member_routines_arg_dimensions(frontend):
# Ensure member has been inlined and arguments adapated
assert len(routine.routines) == 0
assert len([v for v in FindVariables().visit(routine.body) if v.name == 'a']) == 0
assert len([v for v in FindVariables().visit(routine.body) if v.name == 'b']) == 0
assert len([v for v in FindVariables().visit(routine.spec) if v.name == 'a']) == 0
assert len([v for v in FindVariables().visit(routine.spec) if v.name == 'b']) == 0
assigns = FindNodes(Assignment).visit(routine.body)
assert len(assigns) == 2
assert assigns[0].lhs == 'matrix(j, i)' and assigns[0].rhs =='matrix(j, i) + 1'
Expand Down

0 comments on commit d89e2ee

Please sign in to comment.