Skip to content

Commit

Permalink
Fix the broken deferred length strings
Browse files Browse the repository at this point in the history
  • Loading branch information
rjfarmer committed Jul 2, 2023
1 parent e015f62 commit 658ac19
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions gfort2py/module_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,7 @@ def is_deferred_len(self):
# Only needed for things that need an extra function argument for their length
if self.is_char():
try:
self.sym.ts.charlen.value
return False
return self.sym.ts.charlen.value == -1
except AttributeError:
return True
elif self.is_array():
Expand Down Expand Up @@ -467,8 +466,10 @@ class typespec:
type2: str = "" # Repeat of type
charlen: int = -1 # If character
deferred_cl: bool = False # if character and deferred length
args = None

def __init__(self, *args):
self.args = args
self.type = args[0]
if self.type == "CLASS" or self.type == "DERIVED":
self.class_ref = symbol_ref(args[1])
Expand All @@ -482,11 +483,15 @@ def __init__(self, *args):
self.is_iso_c = bool(int(args[4]))
self.type2 = args[5]
try:
self.charlen = expression(
*args[6][0]
) # TODO: might this need to be iterated for mulit-d strings?
if not args[6][0]:
self.charlen = -1
else:
self.charlen = expression(
*args[6][0]
) # TODO: might this need to be iterated for mulit-d strings?
except IndexError:
self.charlen = -1

try:
self.deferred_cl = args[7] == "DEFERRED_CL"
except (TypeError, IndexError):
Expand All @@ -507,12 +512,12 @@ class expression:
_unknown: t.Any = None

def __init__(self, *args):
self._resolved_value = None
if not len(args):
return
self.exp_type = args[0]
self.ts = typespec(*args[1])
self.rank = int(args[2])
self._resolved_value = None

if self.exp_type == "OP":
self._value = None
Expand Down

0 comments on commit 658ac19

Please sign in to comment.