[nem-bug] [Nemerle 0000827]: Weird case-sensitiveness in name binding in pattern matching

feedback at nemerle.org feedback at nemerle.org
Fri Jan 19 17:39:33 CET 2007


The following issue requires your FEEDBACK.
======================================================================
<http://nemerle.org/bugs/view.php?id=827> 
======================================================================
Reported By:                akhropov
Assigned To:                
======================================================================
Project:                    Nemerle
Issue ID:                   827
Category:                   Compiler (match compiler)
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     feedback
======================================================================
Date Submitted:             01-16-2007 23:29 CET
Last Modified:              01-19-2007 17:39 CET
======================================================================
Summary:                    Weird case-sensitiveness in name binding in pattern
matching
Description: 
def i = 5;
def j = 10;

def s = match((i,j)) {
    | (i1,j1) => $"i1 = $i1, j1 = $j1"   // this works
    //| (I1,J1) => $"I1 = $I1, J1 = $J1" /* and this doesn't 
                                            (compiler reckons them to be
type                        
                                             names for some reason)
                                         */
}

System.Console.WriteLine(s);
======================================================================

----------------------------------------------------------------------
 nazgul - 01-19-07 17:39 
----------------------------------------------------------------------
This is by design:

for variants you can specify:

variant {
  | Aa
  | Ab
  | C
}

and use it as:

match (x) {
  | Aa => ..
  | Ab =>..
  | C => ..
}

Now consider such match:

match (x) {
  | Aa => ..
  | Ac => ...
}

without the check you get into, last case would be interpreted as variable
name and match anything, which would be quite ugly bug. So we enforce some
convention to use uppercase for variant types and lowercase of variables
in match cases.

Issue History
Date Modified  Username       Field                    Change              
======================================================================
01-16-07 23:29 akhropov       New Issue                                    
01-19-07 17:39 nazgul         Note Added: 0001609                          
01-19-07 17:39 nazgul         Status                   new => feedback     
01-19-07 17:39 nazgul         Description Updated                          
======================================================================




More information about the bugs mailing list