From c7131211eec2f0260ed6ee836a8ff64d5df7870d Mon Sep 17 00:00:00 2001 From: Joeffrey Legaux Date: Wed, 4 Oct 2023 15:23:02 +0200 Subject: [PATCH 1/2] bugfix : do not hoist the symbols that are in the member dummies, instead of the routine dummies --- loki/transform/transform_inline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From 14c149c33830e0480653646fc0392fcb6584a6a2 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Tue, 10 Oct 2023 05:29:58 +0000 Subject: [PATCH 2/2] TransformInline: Extend test to ensure correct declaration hoisting --- tests/test_transform_inline.py | 3 +++ 1 file changed, 3 insertions(+) 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'