Bug 536801

Summary: gmcs fails to compile some switch expressions in anonymous methods
Product: [Mono] Mono: Compilers Reporter: Leszek Ciesielski <skolima>
Component: C#Assignee: Mono Bugs <mono-bugs>
Status: RESOLVED DUPLICATE QA Contact: Mono Bugs <mono-bugs>
Severity: Normal    
Priority: P5 - None    
Version: SVN   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: test case

Description Leszek Ciesielski 2009-09-04 10:19:36 UTC
Created attachment 316791 [details]
test case

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 (.NET CLR 4.0.20506) AutoPager/0.5.2.2 (http://www.teesoft.info/)

gmcs fails to compile an anonymous method which:
1. Returns a value
2. Contains a 'switch' statement, in which each case 'returns'
3. 'default' case contains a 'return' statement or 'throw'

A workaround is to change the body of the 'default' branch to 'break;' and throw/return the default value after the 'switch'.

Error message: "error CS1643: Not all code paths return a value in anonymous method of type 'X'".

Reproducible: Always

Steps to Reproduce:
A test case is attached. The first switch compiles fine, the second and third do not.
Actual Results:  
Error message: "error CS1643: Not all code paths return a value in anonymous method of type 'X'".

Expected Results:  
The code should compile fine (it does on MS.Net).
Comment 1 Marek Safar 2009-09-24 17:28:13 UTC
duplicate

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