Where head is used (in this case on csMainLocals), protected it with a condition so that it gives a more useful error message than simply head: empty list

This commit is contained in:
Neil Brown 2007-08-22 11:07:56 +00:00
parent 017cb51bd8
commit 849a41fcdd
2 changed files with 3 additions and 0 deletions

1
TLP.hs
View File

@ -39,6 +39,7 @@ data TLPChannel = TLPIn | TLPOut | TLPError
tlpInterface :: (CSM m, Die m) => m (A.Name, [TLPChannel])
tlpInterface
= do ps <- get
when (null $ csMainLocals ps) (die "No main process found")
let mainName = snd $ head $ csMainLocals ps
st <- specTypeOfName mainName
formals <- case st of

View File

@ -29,6 +29,7 @@ import CompState
import EvalConstants
import Metadata
import Pass
import Errors
import Types
unnest :: A.Process -> PassM A.Process
@ -111,6 +112,7 @@ removeFreeNames = doGeneric `extM` doSpecification `extM` doProcess
-- we know it's not going to be moved by removeNesting, so anything
-- that it had in scope originally will still be in scope.
ps <- get
when (null $ csMainLocals ps) (die "No main process found")
let isTLP = (snd $ head $ csMainLocals ps) == n
-- Figure out the free names.