Bug 42611

Summary: wrong compiler error when using IEnumerable.Sum
Product: [Mono] Compilers Reporter: ahmad13932013
Component: C#Assignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: mono-bugs+mono
Priority: ---    
Version: 4.4.0 (C7)   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: the program causing faulty compiler error

Description ahmad13932013 2016-07-16 11:59:43 UTC
Created attachment 16696 [details]
the program causing faulty compiler error

I have this code 
    int? sum = Enumerable.Range(0, 1000).Sum<int>((int i) =>
              {
                  if (((i % 3) == 0) && ((i % 5) == 0))
                      return i;
                  return null;
            });
The expected output : to compile fine(with warnings perhaps)

The actual output : compiler error : error CS0266: Cannot implicitly convert type `decimal?' to `int?'. An explicit conversion exists (are you missing a cast?) (CS0266) (test)

My distro is Arch linux and I have mono 4.4.1 specifically .
Comment 1 Marek Safar 2016-07-29 13:31:47 UTC
Fixed in master and Mono 4.6