rsdn/nemerle — Issue #164: type inference or type conversion issue
Author: zyhong
Created: 2011-10-30 02:25:14+00:00
State: open

using System;

static class Program
{
static void Main(string[] args)
{
//this should compile but got this error:
//...\Program.cs(15,34): error : expected int, got long in array initializer: System.Int64 is not a subtype of System.Int32 [simple require]
//...\Program.cs(15,28): error : expected array[long], got array[int] in type-enforced expression: the types long and int are not compatible [simple unify]

//long[] Intervals = new[] {1, 10, 100, 1000, long.MaxValue };

int i = 1000;
long l = 1000L;
var expectLongButGetInt = (1000L * i);
var expectLongIndeedGetLong = (l * i);
System.Console.WriteLine(expectLongButGetInt.GetType().ToString()); //print System.Int32
System.Console.WriteLine(expectLongIndeedGetLong.GetType().ToString()); //Print System.Int64
System.Console.Read();

}

}