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:
Christopher Haster
2026-01-30 00:43:35 -06:00
parent 9a224a1c52
commit cf7e0e3fef
+4 -1
View File
@@ -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)