Skip to content

Commit

Permalink
Check that the declared type of prims matches the expected one.
Browse files Browse the repository at this point in the history
Fixes #711
  • Loading branch information
yav committed May 5, 2020
1 parent 6adec7f commit c3eca4f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/Cryptol.cry
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ primitive type (!=) : # -> # -> Prop
primitive type (>=) : # -> # -> Prop

/** Assert that a numeric type is a proper natural number (not 'inf'). */
primitive type fin : * -> Prop
primitive type fin : # -> Prop

/** Value types that have a notion of 'zero'. */
primitive type Zero : * -> Prop
Expand Down
10 changes: 9 additions & 1 deletion src/Cryptol/TypeCheck/Type.hs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,15 @@ newtypeConType nt =
abstractTypeTC :: AbstractType -> TCon
abstractTypeTC at =
case builtInType (atName at) of
Just tcon -> tcon
Just tcon
| kindOf tcon == atKind at -> tcon
| otherwise ->
panic "abstractTypeTC"
[ "Mismatch between built-in and declared type."
, "Name: " ++ pretty (atName at)
, "Declared: " ++ pretty (atKind at)
, "Built-in: " ++ pretty (kindOf tcon)
]
_ -> TC $ TCAbstract $ UserTC (atName at) (atKind at)

instance Eq TVar where
Expand Down
2 changes: 1 addition & 1 deletion tests/issues/issue226.icry.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Primitive Types
Arith : * -> Prop
Bit : *
Cmp : * -> Prop
fin : * -> Prop
fin : # -> Prop
Integer : *
inf : #
Literal : # -> * -> Prop
Expand Down

0 comments on commit c3eca4f

Please sign in to comment.