nicer error message for missing struct fields

This commit is contained in:
Zachary Snow 2019-08-26 20:20:38 -04:00
parent 89e4f2a248
commit 086826714d
1 changed files with 4 additions and 1 deletions

View File

@ -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