diff --git a/loopy/type_inference.py b/loopy/type_inference.py index b8b0cbcbf1236cdf712da998922ac238261a3e6e..4df619fea0fc965afd72964004c286e751aa8270 100644 --- a/loopy/type_inference.py +++ b/loopy/type_inference.py @@ -332,8 +332,13 @@ class TypeInferenceMapper(CombineMapper): if not agg_result: return agg_result - field = agg_result[0].numpy_dtype.fields[expr.name] - dtype = field[0] + fields = agg_result[0].numpy_dtype.fields + if fields is None: + raise LoopyError("cannot look up attribute '%s' in " + "non-aggregate expression '%s'" + % (expr.aggregate, expr.name)) + + dtype = fields[0] return [NumpyType(dtype)] def map_comparison(self, expr):