Make protocolItems give a more useful error message on failure.

This commit is contained in:
Adam Sampson 2008-04-06 02:50:46 +00:00
parent e1fca531a0
commit aa3b17b555

View File

@ -261,7 +261,10 @@ returnTypesOfIntrinsic m s
-- Returns Left if it's a simple protocol, Right if it's tagged. -- Returns Left if it's a simple protocol, Right if it's tagged.
protocolItems :: (CSMR m, Die m) => A.Variable -> m (Either [A.Type] [(A.Name, [A.Type])]) protocolItems :: (CSMR m, Die m) => A.Variable -> m (Either [A.Type] [(A.Name, [A.Type])])
protocolItems v protocolItems v
= do A.Chan _ _ t <- typeOfVariable v = do chanT <- typeOfVariable v
t <- case chanT of
A.Chan _ _ t -> return t
_ -> dieP (findMeta v) $ "Expected a channel variable, but this is of type: " ++ show chanT
case t of case t of
A.UserProtocol proto -> A.UserProtocol proto ->
do st <- specTypeOfName proto do st <- specTypeOfName proto