Skip to content

Commit

Permalink
Expression: Fix scoping of intrinsic procedures in scope removal
Browse files Browse the repository at this point in the history
  • Loading branch information
mlange05 committed Nov 2, 2024
1 parent ef677c0 commit 44613f6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion loki/transformations/sanitise.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,17 @@ def map_array(self, expr, *args, **kwargs):

map_variable_symbol = map_scalar
map_deferred_type_symbol = map_scalar
map_procedure_symbol = map_scalar

def map_procedure_symbol(self, expr, *args, **kwargs):
new = self.map_scalar(expr, *args, **kwargs)
# Ensure we re-scope intrinsic procedure symbols
# (which are by default scoped to the closest scope,
# but do not actually have a parent if they happen
# to be created under an associate).
# TODO: Try create on Subroutine, not Associate?
if expr.type.dtype.is_intrinsic:
new = new.clone(scope=new.scope.parent)
return new


class ResolveAssociatesTransformer(Transformer):
Expand Down

0 comments on commit 44613f6

Please sign in to comment.