irken-compiler
irken-compiler copied to clipboard
matching two pvariants with accidentally different sub-types
This appears to be allowed when it should not.
(:thing x (specific:cons) ...)
(:thing x (other:cons) ...)
When I try this, I get "more than one datatype in pattern match (two one)"... which isn't the most descriptive error, but I don't see the problem above...
(datatype one (:a))
(datatype two (:a))
(define (foo a)
(match a with
(:thing x (one:a)) -> 1
(:thing x (two:a)) -> 2
))
Irken does allow this function to be written, but when I call it, it's a type error:
(define (bar a)
(match a with
(:thing x (one:a)) ->
(match a with
(:thing x (two:a)) -> 2)))
(bar (:thing 1 (one:a))) ;; <-- type error