[nem-bug] [Nemerle 0000596]: Addition of two ushorts gives int

feedback at nemerle.org feedback at nemerle.org
Thu Jan 5 08:46:27 CET 2006


A NOTE has been added to this issue.
======================================================================
<http://nemerle.org/bugs/view.php?id=596> 
======================================================================
Reported By:                nazgul
Assigned To:                
======================================================================
Project:                    Nemerle
Issue ID:                   596
Category:                   Compiler
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     feedback
======================================================================
Date Submitted:             01-04-2006 20:24 CET
Last Modified:              01-05-2006 08:46 CET
======================================================================
Summary:                    Addition of two ushorts gives int
Description: 
def x = ((1 : ushort) + (2 : ushort)) : ushort;
======================================================================

----------------------------------------------------------------------
 malekith - 01-05-06 08:00 
----------------------------------------------------------------------
C#:

class M {
  public static void Main ()
  {
        ushort x = 2, y = 7;
        ushort z = x + y;
  }
}


-->

foo.cs(5,9): error CS0266: Cannot implicitly convert type `int' to
`ushort'. An explicit conversion exists (are you missing a cast?)


The reason is that computations on the stack are always performed with
precision of at least int.

----------------------------------------------------------------------
 nazgul - 01-05-06 08:03 
----------------------------------------------------------------------
class M { 
  static void Main () {
ushort x = ((ushort) 1) + ((ushort) 2);
}
}

compiles fine...

----------------------------------------------------------------------
 malekith - 01-05-06 08:46 
----------------------------------------------------------------------
So this is a dup of http://nemerle.org/bugs/view.php?id=344 ?

Issue History
Date Modified  Username       Field                    Change              
======================================================================
01-04-06 20:24 nazgul         New Issue                                    
01-05-06 08:00 malekith       Note Added: 0001053                          
01-05-06 08:00 malekith       Status                   new => feedback     
01-05-06 08:03 nazgul         Note Added: 0001054                          
01-05-06 08:46 malekith       Note Added: 0001055                          
======================================================================




More information about the bugs mailing list