Skip to content

Commit

Permalink
compiler: fix #396 related issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Zilin Chen authored and Zilin Chen committed Mar 19, 2021
1 parent 1f2e543 commit 8d7e015
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cogent/src/Cogent/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,8 @@ polytype = polytype' <|> PT [] [] <$> monotype
flt2 (x, y) | Right v <- y = pure (x, v)
| otherwise = mempty

klSignature = (,) <$> variableName <*> (Left <$> (reservedOp ":<" *> kind <?> "kind")
<|> Right <$> (reservedOp ":~" *> atomtype <?> "typeid")
klSignature = (,) <$> variableName <*> (Left <$> (reservedOp ":<" *> kind <?> "uniqueness constraint")
<|> Right <$> (reservedOp ":~" *> monotype <?> "layout-type matching constraint")
<|> Left <$> (pure $ K False False False))
where kind = do x <- identifier
determineKind x (K False False False)
Expand Down
6 changes: 1 addition & 5 deletions cogent/src/Cogent/TypeCheck/Solver/Simplify.hs
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,6 @@ simplify ks lts = Rewrite.pickOne' $ onGoal $ \case
TLArray e1 _ :~< TLArray e2 _ -> hoistMaybe $ Just [e1 :~< e2]
#endif

l1 :~< l2 | TLU _ <- l1 -> hoistMaybe Nothing
| TLU _ <- l2 -> hoistMaybe Nothing
| otherwise -> unsat $ LayoutsNotCompatible l1 l2 -- FIXME!

t1 :~~ t2 | isBoxedType t1, isBoxedType t2 -> hoistMaybe $ Just [] -- If both are pointers, then their layouts will be compatible

T (TVar n1 _ _) :~~ T (TVar n2 _ _) | n1 == n2 -> hoistMaybe $ Just []
Expand All @@ -259,7 +255,7 @@ simplify ks lts = Rewrite.pickOne' $ onGoal $ \case
| isPrimType t1 && isPrimType t2
, primTypeSize t1 <= primTypeSize t2
-> hoistMaybe $ Just []
| otherwise -> unsat $ TypesNotFit t1 t2
| otherwise -> hoistMaybe Nothing

T (TFun t1 t2) :=: T (TFun r1 r2) -> hoistMaybe $ Just [r1 :=: t1, t2 :=: r2]
T (TFun t1 t2) :< T (TFun r1 r2) -> hoistMaybe $ Just [r1 :< t1, t2 :< r2]
Expand Down
1 change: 1 addition & 0 deletions cogent/tests/tests/dargent/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- pass_inner-synonym.cogent
- pass_layout-poly.cogent
- pass_dargent-unspec.cogent
- pass_l-matches-record.cogent
expected_result: pass
flags:
- -g
Expand Down
2 changes: 2 additions & 0 deletions cogent/tests/tests/dargent/pass_l-matches-record.cogent
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
main : all (l :~ #{a : U8} ). {a : U8} layout l -> {a : U8} layout l
main x = x

0 comments on commit 8d7e015

Please sign in to comment.