From 1987b85ebfbcd275dc9444641cbdd0d2e1ee5679 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Wed, 9 Oct 2024 04:47:42 +0000 Subject: [PATCH] Extract: Ensure correct re-scoping after cloning arguments --- loki/transformations/extract/outline.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/loki/transformations/extract/outline.py b/loki/transformations/extract/outline.py index 2299c04d9..8cf766bbd 100644 --- a/loki/transformations/extract/outline.py +++ b/loki/transformations/extract/outline.py @@ -127,7 +127,8 @@ def outline_region(region, name, imports, intent_map=None): local_var = region_routine_var_map.get(arg.name, arg) # Sanitise argument types local_var = local_var.clone( - type=local_var.type.clone(intent=intent, allocatable=None, target=None) + type=local_var.type.clone(intent=intent, allocatable=None, target=None), + scope=region_routine ) region_routine_var_map[arg.name] = local_var @@ -143,6 +144,9 @@ def outline_region(region, name, imports, intent_map=None): region_routine.variables = region_routine_arguments + region_routine_locals region_routine.arguments = region_routine_arguments + # Ensure everything has been rescoped + region_routine.rescope_symbols() + # Create the call according to the wrapped code region call_arg_map = {v.name: v for v in region_in_args + region_inout_args + region_out_args} call_arguments = tuple(call_arg_map[a.name] for a in region_routine_arguments)