au-ts / cogent

Cogent Project
https://trustworthy.systems/projects/TS/cogent.pml
Other
158 stars 26 forks source link

Numeric types are compatible with Bool. #312

Closed gteege closed 4 years ago

gteege commented 4 years ago

The code

f: Bool -> ()
f b = ()

g: () -> ()
g () = f 100000

compiles successfully. If this is intended as an implicit type conversion from numeric to Bool, you have a problem in Dargent: when specifying a layout size of 1b for a field of type Bool, a put numeric value will simply be masked to the least significant bit. This will convert all even values to false and all odd values to true.

zilinc commented 4 years ago

Emmm, that's a good observation. We'll fix it. Thank you.

zilinc commented 4 years ago

Related: #285