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

feedback at nemerle.org feedback at nemerle.org
Tue Aug 1 03:21:45 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:              08-01-2006 03:21 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
}

----------------------------------------------------------------------
 VladD2 - 07-31-06 23:10 
----------------------------------------------------------------------
I agree with Snaury.

----------------------------------------------------------------------
 IT - 08-01-06 03:21 
----------------------------------------------------------------------
Got it. If/else is more an operator than a statement. But it's confusing at
least for beginning.

This issue needs to be closed.

Issue History
Date Modified  Username       Field                    Change              
======================================================================
07-31-06 08:51 IT             New Issue                                    
07-31-06 09:39 Snaury         Note Added: 0001383                          
07-31-06 23:10 VladD2         Note Added: 0001384                          
08-01-06 03:21 IT             Note Added: 0001385                          
======================================================================




More information about the bugs mailing list