diff --git a/loki/transform/transform_inline.py b/loki/transform/transform_inline.py index dd7085304..ebd30bc9c 100644 --- a/loki/transform/transform_inline.py +++ b/loki/transform/transform_inline.py @@ -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) diff --git a/tests/test_transform_inline.py b/tests/test_transform_inline.py index 16b4f9e96..3487bc83a 100644 --- a/tests/test_transform_inline.py +++ b/tests/test_transform_inline.py @@ -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'