[nem-bug] [Nemerle 0000724]: if/else & return values

feedback at nemerle.org feedback at nemerle.org
Mon Jul 31 09:39:02 CEST 2006


A NOTE has been added to this issue.
======================================================================
<http://nemerle.org/bugs/view.php?id=724> 
======================================================================
Reported By:                IT
Assigned To:                
======================================================================
Project:                    Nemerle
Issue ID:                   724
Category:                   The Macro Library
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
======================================================================
Date Submitted:             07-31-2006 08:51 CEST
Last Modified:              07-31-2006 09:39 CEST
======================================================================
Summary:                    if/else & return values
Description: 
This code gives me an error:

def foo() : int
{
  if (1 > 2)
  {
    _ = 1;
  }
  else
    3
  4
}

_ = foo();

======================================================================

----------------------------------------------------------------------
 Snaury - 07-31-06 09:39 
----------------------------------------------------------------------
I don't see any bug here. First, you should have written it like this:

def foo() : int
{
  if (1 > 2)
  {
    _ = 1;
  }
  else
    3;
  4
}

But then you'd get different values (void and int) in different branches
of int, so it really should have been:

def foo() : int
{
  if (1 > 2)
  {
    _ = 1;
  }
  else
    _ = 3;
  4
}

Issue History
Date Modified  Username       Field                    Change              
======================================================================
07-31-06 08:51 IT             New Issue                                    
07-31-06 09:39 Snaury         Note Added: 0001383                          
======================================================================




More information about the bugs mailing list