hazelgrove / hazel

Hazel, a live functional programming environment with typed holes
http://hazel.org/
MIT License
684 stars 45 forks source link

ListLit of different Construtor type does not raise type error #1313

Open GuoDCZ opened 1 month ago

GuoDCZ commented 1 month ago

The following code should have a static error Elements have inconsistent types: ...in 5th line, but is mistakenly accepted in Hazel: image

type A = +A in
let a = A in
type B = +A in
let b = A in
[a, b]
Negabinary commented 1 month ago

I think this is actually intentional. You're right that this would be a bug in OCaml, where every sum type is treated as different, but in Hazel the type keyword is literally just an alias. In Hazel you can also write that code like:

let a : +A = A in
let b : +A = A in
[a,b]