From e413c8ca30c2e5ac99664f2cc55fe589f40d5c7f Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Mon, 24 Oct 2011 00:38:38 -0400
Subject: [PATCH] Better error message for wrong invocation of reduction ops.

---
 loopy/symbolic.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/loopy/symbolic.py b/loopy/symbolic.py
index 054ed8781..725fbad3b 100644
--- a/loopy/symbolic.py
+++ b/loopy/symbolic.py
@@ -109,8 +109,11 @@ class FunctionToPrimitiveMapper(IdentityMapper):
                     raise TypeError("invalid 'reduce' calling sequence")
             else:
                 from loopy.kernel import parse_reduction_op
-                if (parse_reduction_op(expr.function.name) 
-                        and len(expr.parameters) == 2):
+                if parse_reduction_op(expr.function.name):
+                    if len(expr.parameters) != 2:
+                        raise RuntimeError("invalid invocation of "
+                                "reduction operation '%s'" % expr.function.name)
+
                     operation = expr.function
                     inames, red_expr = expr.parameters
                 else:
-- 
GitLab