Skip to content

Commit

Permalink
Sanitise: Only apply partial range resolution if new symbols has dims
Browse files Browse the repository at this point in the history
Also slightly adjust the simply associate resolver test case to cover
this basic use case.
  • Loading branch information
mlange05 committed Dec 6, 2024
1 parent 344d098 commit c055d93
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion loki/transformations/sanitise/associates.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def map_array(self, expr, *args, **kwargs):
new = self.map_scalar(expr, *args, **kwargs)

# Recurse over array dimensions
if isinstance(new, sym.Array):
if isinstance(new, sym.Array) and new.dimensions:
# Resolve unbound range symbols form existing indices
new_dims = self.rec(new.dimensions, *args, **kwargs)
new_dims = self._match_range_indices(new_dims, expr_dims)
Expand Down
6 changes: 3 additions & 3 deletions loki/transformations/sanitise/tests/test_associates.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_transform_associates_simple(frontend):
real :: local_var
associate (a => some_obj%a)
local_var = a
local_var = a(:)
end associate
end subroutine transform_associates_simple
"""
Expand All @@ -42,7 +42,7 @@ def test_transform_associates_simple(frontend):
assert len(FindNodes(ir.Associate).visit(routine.body)) == 1
assert len(FindNodes(ir.Assignment).visit(routine.body)) == 1
assign = FindNodes(ir.Assignment).visit(routine.body)[0]
assert assign.rhs == 'a' and 'some_obj' not in assign.rhs
assert assign.rhs == 'a(:)' and 'some_obj' not in assign.rhs
assert assign.rhs.type.dtype == BasicType.DEFERRED

# Now apply the association resolver
Expand All @@ -51,7 +51,7 @@ def test_transform_associates_simple(frontend):
assert len(FindNodes(ir.Associate).visit(routine.body)) == 0
assert len(FindNodes(ir.Assignment).visit(routine.body)) == 1
assign = FindNodes(ir.Assignment).visit(routine.body)[0]
assert assign.rhs == 'some_obj%a'
assert assign.rhs == 'some_obj%a(:)'
assert assign.rhs.parent == 'some_obj'
assert assign.rhs.type.dtype == BasicType.DEFERRED
assert assign.rhs.scope == routine
Expand Down

0 comments on commit c055d93

Please sign in to comment.