[Mono-bugs] [Bug 660569] New: code analysis error when using a switch within a lamda: "Not all code paths return a value in anonymous method"

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Dec 20 11:55:20 EST 2010


https://bugzilla.novell.com/show_bug.cgi?id=660569

https://bugzilla.novell.com/show_bug.cgi?id=660569#c0


           Summary: code analysis error when using a switch within a
                    lamda: "Not all code paths return a value in anonymous
                    method"
    Classification: Mono
           Product: Mono: Compilers
           Version: 2.8.x
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: msafar at novell.com
        ReportedBy: david at dasz.at
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US)
AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.224 Safari/534.10

ccnet at squeeze:~/tmp$ cat switch-return.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

public class Test {
        public static IEnumerable<int> Error(IEnumerable<BindingFlags> f) {
                return f.Select(p => {
                        switch(p)
                        {
                                case BindingFlags.Default:
                                        return 1;
                                default:
                                        return 2;
                        };
                });
        }
        public static int Works(BindingFlags f) {
                switch(f)
                {
                        case BindingFlags.Default:
                                return 1;
                        default:
                                return 2;
                }
        }
}

ccnet at squeeze:~/tmp$ gmcs /t:library switch-return.cs
switch-return.cs(8,33): error CS1643: Not all code paths return a value in
anonymous method of type `System.Func<TSource,TResult>'
Compilation failed: 1 error(s), 0 warnings


Reproducible: Always

Steps to Reproduce:
1. Compile the example code
Actual Results:  
switch-return.cs(8,33): error CS1643: Not all code paths return a value in
anonymous method of type `System.Func<TSource,TResult>'
Compilation failed: 1 error(s), 0 warnings


Expected Results:  
should compile without error

This works in CSC 2010, but neither with gmcs 2.8.1 nor 2.6.7.0

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list