Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions scripts/metavar.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ class Var:
# All constituent props are optional so no check

def __init__(self, prop_dict, source, run_env, context=None,
clone_source=None):
clone_source=None, skip_checks=False):
"""Initialize a new Var object.
If <prop_dict> is really a Var object, use that object's prop_dict.
If this Var object is a clone, record the original Var object
Expand Down Expand Up @@ -360,19 +360,21 @@ def __init__(self, prop_dict, source, run_env, context=None,
# # end if
# # end for
# XXgoldyXX: ^ don't fill in default properties?
# Make sure all the variable values are valid
try:
for prop_name, prop_val in self.var_properties():
prop = Var.get_prop(prop_name)
_ = prop.valid_value(prop_val,
prop_dict=self._prop_dict, error=True)
# end for
except CCPPError as cperr:
lname = self._prop_dict['local_name']
emsg = "{}: {}"
raise ParseSyntaxError(emsg.format(lname, cperr),
context=self.context) from cperr
# end try
# Make sure all the variable values are validi
if not skip_checks:
try:
for prop_name, prop_val in self.var_properties():
prop = Var.get_prop(prop_name)
_ = prop.valid_value(prop_val,
prop_dict=self._prop_dict, error=True)
# end for
except CCPPError as cperr:
lname = self._prop_dict['local_name']
emsg = "{}: {}"
raise ParseSyntaxError(emsg.format(lname, cperr),
context=self.context) from cperr
# end try
# end if

def compatible(self, other, run_env, is_tend=False):
"""Return a VarCompatObj object which describes the equivalence,
Expand Down Expand Up @@ -1209,9 +1211,10 @@ def __init__(self, prop_dict, source, run_env, context=None,
del prop_dict[prop.name]
# end if
# end for
# Initialize Var
# Initialize Var; skip the parse checkers on the Fortran side since the
# checks are already done during metadata parsing
super().__init__(prop_dict, source, run_env, context=context,
clone_source=clone_source)
clone_source=clone_source, skip_checks=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like the wrong place to add this check as the problem (which I do not really follow without a regression test to read) is not within this type but its use in parse_fortran.py.
I suggest adding skip_checks as an input to the __init__ method for this class and calling it from parse_fortran.py

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added some new test files to the ddthost test that will cause the test to fail without the changes in this PR. Hope that helps - and thanks for the suggestion to add a test.

I'm not sure I'm following your suggestion here. The checks are done in super().__init__ so I don't know how to avoid passing the skip_checks into there. I figured since the FortranVar class is only used during fortran parsing, it would be unnecessary to add the flag to the FortranVar.__init__. But if I'm missing something please let me know!

# Now, restore the saved properties
for prop in save_dict:
self._prop_dict[prop] = save_dict[prop]
Expand Down