Bug 660569 - code analysis error when using a switch within a lamda: "Not all code paths return a value in anonymous method"
Summary: code analysis error when using a switch within a lamda: "Not all code paths r...
Status: RESOLVED DUPLICATE of bug 336258
Alias: None
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 2.8.x
Hardware: Other Other
: P5 - None : Normal
Target Milestone: ---
Assignee: Marek Safar
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-20 16:55 UTC by David Schmitt
Modified: 2010-12-20 19:28 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Schmitt 2010-12-20 16:55:19 UTC
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@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@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
Comment 1 Marek Safar 2010-12-20 19:28:56 UTC
duplicate

*** This bug has been marked as a duplicate of bug 336258 ***