on master help sign in
Properly check for WritableStream types
commit2a6e92bbc13b1a6fc04965dd50a68d3f5580d8ab authorEvan Czaplicki <info@elm-lang.org> dateSat 28 Feb 2015, 16:57 (12 years ago) parentdc6668d
2 files changed+15−10
src/AST/Variable.hs+3−3 src/Type/ExtraChecks.hs+12−7
src/AST/Variable.hs+3−3
@@ -68,9 +68,9 @@ isStream =
6868 is ["Signal"] "Stream"
6969
7070
71−isWritableStream :: Canonical -> Bool
72−isWritableStream =
73− is ["Signal"] "WritableStream"
71+isMailbox :: Canonical -> Bool
72+isMailbox =
73+ is ["Mailbox"] "Mailbox"
7474
7575
7676isVarying :: Canonical -> Bool
src/Type/ExtraChecks.hs+12−7
@@ -261,18 +261,23 @@ checkLoobacks name tipe hasExpr =
261261
262262checkLoobacksHelp :: String -> ST.CanonicalType -> ST.CanonicalType -> Bool -> Either [P.Doc] ()
263263checkLoobacksHelp name rootType tipe hasExpr =
264− case tipe of
265− ST.Aliased _ t ->
266− checkLoobacksHelp name rootType t hasExpr
264+ case ST.dealias tipe of
265+ ST.Record
266+ [ ("mailbox", ST.App (ST.Type mailbox) [a])
267+ , ("stream", ST.App (ST.Type stream) [b])
268+ ]
269+ Nothing
270+ | not hasExpr
271+ && Var.isStream stream
272+ && Var.isMailbox mailbox
273+ && a == b
274+ ->
275+ return ()
267276
268277 ST.App (ST.Type signal) [ ST.App (ST.Type result) [_,_] ]
269278 | hasExpr && Var.isStream signal && Var.isResult result ->
270279 return ()
271280
272− ST.App (ST.Type signal) [ _ ]
273− | not hasExpr && Var.isWritableStream signal ->
274− return ()
275−
276281 _ ->
277282 throw $
278283 [ P.text "Loopback Error:"