Skip to content

Commit 04e347d

Browse files
committed
#2845 alter validate to check routine symbol table
1 parent 2307ac7 commit 04e347d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/psyclone/psyir/transformations/inline_trans.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,10 @@ def apply(self, node, options=None):
226226
# the ancestor Routine. This avoids issues like #2424 when
227227
# applying ParallelLoopTrans to loops containing inlined calls.
228228
if ancestor_table is not scope.symbol_table:
229-
ancestor_table.merge(scope.symbol_table)
229+
try:
230+
ancestor_table.merge(scope.symbol_table)
231+
except SymbolError as err:
232+
raise InternalError("No escape") from err
230233
replacement = type(scope.symbol_table)()
231234
scope.symbol_table.detach()
232235
replacement.attach(scope)
@@ -673,7 +676,8 @@ def validate(self, node, options=None):
673676
f"Routine '{routine.name}' cannot be inlined because it "
674677
f"has a named argument '{arg}' (TODO #924).")
675678

676-
table = node.scope.symbol_table
679+
parent_routine = node.ancestor(Routine)
680+
table = parent_routine.symbol_table # node.scope.symbol_table
677681
routine_table = routine.symbol_table
678682

679683
for sym in routine_table.datasymbols:
@@ -693,7 +697,10 @@ def validate(self, node, options=None):
693697
raise TransformationError(
694698
f"Routine '{routine.name}' cannot be inlined because it "
695699
f"contains a Symbol '{sym.name}' with an UnknownInterface:"
696-
f" '{sym.datatype.declaration}'")
700+
f" '{sym.datatype.declaration}'. You may be able to work "
701+
f"around this limitation by adding the name of the module "
702+
f"containing this Symbol to RESOLVE_IMPORTS in the "
703+
f"transformation script.")
697704
# Check that there are no static variables in the routine (because
698705
# we don't know whether the routine is called from other places).
699706
if (isinstance(sym.interface, StaticInterface) and

0 commit comments

Comments
 (0)