[nem-bug] [Nemerle 0000922]: Pattern matching does not work as expected

feedback at nemerle.org feedback at nemerle.org
Sun Apr 29 19:49:14 CEST 2007


The following issue requires your FEEDBACK.
======================================================================
<http://nemerle.org/bugs/view.php?id=922> 
======================================================================
Reported By:                nikov
Assigned To:                
======================================================================
Project:                    Nemerle
Issue ID:                   922
Category:                   Compiler (match compiler)
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     feedback
======================================================================
Date Submitted:             02-20-2007 17:10 CET
Last Modified:              04-29-2007 19:49 CEST
======================================================================
Summary:                    Pattern matching does not work as expected
Description: 
[nemerle]
using System;
using System.Console;
using Nemerle.Utility;

module Program
{
  Main() : void
  {
    def s = [ (1, 2), (2, 3) ];
    WriteLine(Foo(s));
  }

  Foo(o : object) : string {
    match(o) {
        | [ _, (x is int, y is int) ] => $"($x, $y)"
        | _ => "bugaga"
    }
  }
}
[/nemerle]

Current output:

[output]
bugaga
[/output]

Expected:

[output]
(2, 3)
[/output]

======================================================================
Relationships       ID      Summary
----------------------------------------------------------------------
related to          0000931 Pattern matching does not work as expec...
======================================================================

----------------------------------------------------------------------
 nikov - 02-21-07 10:47 
----------------------------------------------------------------------
It tries to cast o to list[object].
But list[int * int] is not a subtype of list[object], so it fails.
It should get list element type from pattern.

----------------------------------------------------------------------
 malekith - 04-29-07 19:49 
----------------------------------------------------------------------
This code should fail at compile time. You're not supposed to match objects
with list patterns. One is only supposed to match objects against type test
patterns. Exactly for the reasons why it fails on the runtime... 

Issue History
Date Modified  Username       Field                    Change              
======================================================================
02-20-07 17:10 nikov          New Issue                                    
02-20-07 17:16 nikov          Summary                  Pattern mathing does not
work as expected => Pattern matching does not work as expected
02-20-07 17:16 nikov          Description Updated                          
02-20-07 18:23 nikov          Description Updated                          
02-21-07 10:47 nikov          Note Added: 0001761                          
02-21-07 14:56 nikov          Relationship added       related to 0000931  
04-29-07 19:49 malekith       Note Added: 0001853                          
04-29-07 19:49 malekith       Status                   new => feedback     
04-29-07 19:49 malekith       Description Updated                          
======================================================================




More information about the bugs mailing list