scripts: csv.py: Tweaked foldchecking to check that folds match
I mean, what would you expect this to do? max(a) + sum(b) Whatever your answer is, it's wrong (the way csv.py works, we always compute folds after expr evaluation). The best option is to error, matching the behavior of mismatched types.
This commit is contained in:
+4
-1
@@ -538,7 +538,10 @@ class CsvExpr:
|
||||
return t
|
||||
|
||||
def fold(self, types={}):
|
||||
return self.a.fold(types)
|
||||
f = self.a.fold(types)
|
||||
if not all(f == v.fold(types) for v in it.islice(self, 1, None)):
|
||||
raise CsvExpr.Error("mismatched folds? %r" % self)
|
||||
return f
|
||||
|
||||
def eval(self, fields={}, state=None):
|
||||
return self.a.eval(fields, state)
|
||||
|
||||
Reference in New Issue
Block a user