cogent icon indicating copy to clipboard operation
cogent copied to clipboard

Simple layout polymorphic function fails

Open amblafont opened this issue 3 years ago • 3 comments

Cogent fails to compile this function, on master:

main : all (l :~ {a : U8} ). {a : U8} layout l -> {a : U8} layout l
main x = x

I get the output:

Parsing...
Resolving dependencies...
Typechecking...
Error: The layout of type 
   R ❲a : U8 (present) | ✗❳ [U]
 does not fit the layout of type 
   R ❲a : U8 (present) | ✗❳ [W] ()
   in the definition at ("simplepoly.cogent" (line 3, column 1))
   for the function main
Error: The layout of type 
   R ❲a : U8 (present) | ✗❳ [U]
 does not fit the layout of type 
   R ❲a : U8 (present) | ✗❳ [W] ()
   in the definition at ("simplepoly.cogent" (line 3, column 1))
   for the function main
Compilation failed!

amblafont avatar Mar 19 '21 02:03 amblafont

The above example is expected to fail because l is a layout for a pointer. However, the following also fails:

main : all (l :~ (#{a : U8}) ). {a : U8} layout l -> {a : U8} layout l
main x = x

amblafont avatar Mar 19 '21 02:03 amblafont

it also fails on main : all (t, l :~ t ). t layout l -> t layout l

amblafont avatar Mar 19 '21 02:03 amblafont

8d7e015 fixes the first problem, and also parens around the RHS of :~ is no longer required.

zilinc avatar Mar 19 '21 02:03 zilinc