Ticket #175 (closed defect: fixed)

Opened 5 years ago

Last modified 4 years ago

Bad pattern match code generated for list comprehension

Reported by: erikd Owned by: erikd
Priority: blocker Milestone: 0.1.3
Component: Core to Sea Translation Version:
Keywords: Cc:

Description

This code:

main ()
 = println $ show [ x |  xs <- [ [(1,2),(3,4)], [(5,4),(3,2)] ], (3,x) <- xs ]

compiles, but when run terminates with the error:

*** DDC RTS: Non-exhaustive patterns in ?:0:0

This is actually two bugs:

  • Failure to give a valid source position (?:0:0) for the error.
  • Non-exhaustive pattern match.

Attachments

175.dpatch (191.9 kB) - added by benl 4 years ago.

Change History

Changed 5 years ago by erikd

  • owner set to erikd
  • status changed from new to assigned

Changed 4 years ago by erikd

  • summary changed from RTS : Non-exhaustive pattern match to Bad pattern match code generated for list comprehension

The pattern match inside the list comprehension gets desugared to (from -dump-desugar output):

Data.List.concatMap 
        (\xSD0 ->
        match {
                | Data.Tuple.Tuple2 {.0 = xSD2, .1 = Main.x} <- xSD0
                , Base.True {} <- Class.Eq.(==) (3i32) xSD2
                = Data.List.Cons Main.x Data.List.Nil;
        }) Main.xs;

This would be correct for a standard pattern match, not for inside a list comprehension. Inside an LC, individual failed matches should result in an empty list element.

Changed 4 years ago by batterseapower

I have a patch for this at http://www.omega-prime.co.uk/files/ddc/175.dpatch which you may wish to apply

I would attach it to the ticket but Trac said "permission denied" when I tried.

Changed 4 years ago by benl

Changed 4 years ago by benl

  • status changed from assigned to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.