irken-compiler icon indicating copy to clipboard operation
irken-compiler copied to clipboard

matching two pvariants with accidentally different sub-types

Open samrushing opened this issue 12 years ago • 2 comments

This appears to be allowed when it should not.

(:thing x (specific:cons) ...)
(:thing x (other:cons) ...)

samrushing avatar Feb 25 '13 04:02 samrushing

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
  ))

jeske avatar May 24 '17 19:05 jeske

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

jeske avatar May 24 '17 19:05 jeske