Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix : symbols from the inlined member's dummies were hoisted in the calling routine #162

Merged
merged 2 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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