Commit 515d1c9e authored by Björn Peemöller 's avatar Björn Peemöller
Browse files

Type checking proceeds only without recursive type synonyms - fixes #489

Prior to this change, recursive type synonyms (which are not allowed)
where checked and the respective errors generated, but the type checking
proceeded. Because the type synonyms are then inserted into the type
environment in their expanded form, an infinite loop occurred.
parent c8496914
......@@ -68,8 +68,8 @@ The type checker returns the resulting type constructor and type environments.
> -> (TCEnv, ValueEnv, [Message])
> typeCheck m tcEnv tyEnv decls = execTCM check initState
> where
> check = do
> checkTypeSynonyms m tds
> check = checkTypeSynonyms m tds `andIfOkay` checkDecls
> checkDecls = do
> bindTypes tds
> bindConstrs
> bindLabels
......@@ -132,6 +132,11 @@ generating fresh type variables.
> report :: Message -> TCM ()
> report err = S.modify $ \ s -> s { errors = err : errors s }
> andIfOkay :: TCM () -> TCM () -> TCM ()
> andIfOkay pre suf = do
> errs <- pre >> S.gets errors
> if null errs then suf else return ()
> execTCM :: TCM a -> TcState -> (TCEnv, ValueEnv, [Message])
> execTCM tcm s = let s' = S.execState tcm s
> in ( tyConsEnv s'
......
Loading this module (in pakcs) leads to cymake <<loop>>.
it might be interesting that the last line is important for this error to
occur; if the last line is omitted or changed to "i = 3" then the expected
error "recursive synonym types" is properly printed.
> module Bug489 where
> type A = B
> type B = A
> i = Just ()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment