[nem-bug] [Nemerle 0000619]: Losing type coersion between short and
int
feedback at nemerle.org
feedback at nemerle.org
Thu Feb 16 05:06:26 CET 2006
A NOTE has been added to this issue.
======================================================================
<http://nemerle.org/bugs/view.php?id=619>
======================================================================
Reported By: kanru
Assigned To:
======================================================================
Project: Nemerle
Issue ID: 619
Category: Compiler (type engine)
Reproducibility: always
Severity: minor
Priority: normal
Status: feedback
======================================================================
Date Submitted: 02-15-2006 07:27 CET
Last Modified: 02-16-2006 05:06 CET
======================================================================
Summary: Losing type coersion between short and int
Description:
mutable s : short = 0;
s = s + 2;
s += 2;
mutable u : byte = 0;
u = u + 2;
u += 2;
Compiling above code got:
t.n:2:1:2:10: error: expected System.Int16, got int in assigned value:
System.Int32 is not a subtype of System.Int16 [simple require]
t.n:3:1:3:7: error: expected System.Int16, got int in assigned value:
System.Int32 is not a subtype of System.Int16 [simple require]
t.n:5:1:5:10: error: expected System.Byte, got int in assigned value:
System.Int32 is not a subtype of System.Byte [simple require]
t.n:6:1:6:7: error: expected System.Byte, got int in assigned value:
System.Int32 is not a subtype of System.Byte [simple require]
Seems the compiler always treats number_literal as Int32.
======================================================================
Relationships ID Summary
----------------------------------------------------------------------
related to 0000596 Addition of two ushorts gives int
======================================================================
----------------------------------------------------------------------
malekith - 02-15-06 19:53
----------------------------------------------------------------------
The uint testcase seems like a bug (it also shouldn't work).
As for the other testcases -- C# doesn't allow x = x + 2 too, but it
allows x += 2 for some strange reason. It is to be reconsidered what
behavior we want. But I don't see a reason x += 2 should be allowed and x
= x + 2 not.
----------------------------------------------------------------------
nazgul - 02-15-06 20:08
----------------------------------------------------------------------
I think that this difference between += and + is lame in C#.
I would prefer allowing to add two shorts and get a short.
----------------------------------------------------------------------
kanru - 02-16-06 05:06
----------------------------------------------------------------------
Hmm... I did not notice that C# also doesn't allow x = x + 2.
BTW, The uint testcase also works in C#.
So, what I expected is that adding two short will get a short too. This
may cause overflows so it need an explicit conversion. (Am I right?)
Issue History
Date Modified Username Field Change
======================================================================
02-15-06 07:27 kanru New Issue
02-15-06 19:53 malekith Note Added: 0001086
02-15-06 19:53 malekith Status new => confirmed
02-15-06 19:53 malekith Description Updated
02-15-06 19:53 malekith Additional Information Updated
02-15-06 19:53 malekith Status confirmed => feedback
02-15-06 19:53 malekith Description Updated
02-15-06 19:53 malekith Additional Information Updated
02-15-06 20:02 nazgul Relationship added related to 0000596
02-15-06 20:08 nazgul Note Added: 0001087
02-16-06 05:06 kanru Note Added: 0001088
======================================================================
More information about the bugs
mailing list