From 9b1f05df009123ae03b2a9c7971a06e148c4e56c Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Thu, 2 Jan 2020 19:51:19 -0800 Subject: concretizer bugfix: fix generations of conditionals for dependencies Spack was generating the same dependency connstraints twice in the output ASP: ``` declared_dependency("abinit", "hdf5", "link") :- node("abinit"), variant_value("abinit", "mpi", "True"), variant_value("abinit", "mpi", "True"). ``` This was because `AspFunction` was modifying itself when called. - [x] fix `AspFunction` so that every call returns a new object --- lib/spack/spack/solver/asp.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index 969e1997df..7701f38620 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -73,13 +73,12 @@ def _id(thing): class AspFunction(AspObject): - def __init__(self, name): + def __init__(self, name, args=None): self.name = name - self.args = [] + self.args = [] if args is None else args def __call__(self, *args): - self.args[:] = args - return self + return AspFunction(self.name, args) def __getitem___(self, *args): self.args[:] = args @@ -89,6 +88,9 @@ class AspFunction(AspObject): return "%s(%s)" % ( self.name, ', '.join(_id(arg) for arg in self.args)) + def __repr__(self): + return str(self) + class AspAnd(AspObject): def __init__(self, *args): @@ -394,6 +396,7 @@ class AspGenerator(object): *self.spec_clauses(named_cond, body=True) ) ) + self.out.write('\n') # virtual preferences self.virtual_preferences( -- cgit v1.2.3-60-g2f50