From 086826714d18732889e0d9b32b9ad433d429fe2f Mon Sep 17 00:00:00 2001 From: Zachary Snow Date: Mon, 26 Aug 2019 20:20:38 -0400 Subject: [PATCH] nicer error message for missing struct fields --- src/Convert/Struct.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Convert/Struct.hs b/src/Convert/Struct.hs index 96d4bf1..61acc09 100644 --- a/src/Convert/Struct.hs +++ b/src/Convert/Struct.hs @@ -446,7 +446,10 @@ convertAsgn structs types (lhs, expr) = -- lookup the range of a field in its unstructured type lookupUnstructRange :: TypeFunc -> Identifier -> Range lookupUnstructRange structTf fieldName = - fieldRangeMap Map.! fieldName + case Map.lookup fieldName fieldRangeMap of + Nothing -> error $ "field '" ++ fieldName ++ + "' not found in struct: " ++ show structTf + Just r -> r where fieldRangeMap = Map.map fst $ snd $ structs Map.! structTf -- lookup the type of a field in the given field list