From 8a975bf6377cad89412573623906c2117cfcd2ff Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Mon, 25 Nov 2024 13:31:41 +0000 Subject: [PATCH] Frontend: Force `ProcedureSymbol` for struct constructors --- loki/frontend/fparser.py | 2 +- loki/frontend/omni.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/loki/frontend/fparser.py b/loki/frontend/fparser.py index 9564c2d0e..8a48066d4 100644 --- a/loki/frontend/fparser.py +++ b/loki/frontend/fparser.py @@ -2602,7 +2602,7 @@ def visit_Structure_Constructor(self, o, **kwargs): # `name` is a DerivedType but we represent a constructor call as InlineCall for # which we need ProcedureSymbol - name = sym.Variable(name=name.name, scope=scope) + name = sym.ProcedureSymbol(name=name.name, scope=scope) if o.children[1] is not None: arguments = self.visit(o.children[1], **kwargs) diff --git a/loki/frontend/omni.py b/loki/frontend/omni.py index 833cb5ffa..89997165e 100644 --- a/loki/frontend/omni.py +++ b/loki/frontend/omni.py @@ -1253,10 +1253,12 @@ def visit_functionCall(self, o, **kwargs): return sym.InlineCall(name, parameters=args, kw_parameters=kw_args) def visit_FstructConstructor(self, o, **kwargs): + scope = kwargs['scope'] _type = self.type_from_type_attrib(o.attrib['type'], **kwargs) assert isinstance(_type.dtype, DerivedType) - name = sym.Variable(name=_type.dtype.name) + # The constructor is represented as an InlineCall with a ProcedureSymbol + name = sym.ProcedureSymbol(name=_type.dtype.name, scope=scope) args = [self.visit(a, **kwargs) for a in o] # Separate keyword argument from positional arguments