[mcs] Better error reporting for incorrect implicitly typed local variable declaratio...
authorMarek Safar <marek.safar@gmail.com>
Thu, 16 Apr 2015 14:30:21 +0000 (16:30 +0200)
committerMarek Safar <marek.safar@gmail.com>
Thu, 16 Apr 2015 14:31:26 +0000 (16:31 +0200)
mcs/errors/cs0815-8.cs [new file with mode: 0644]
mcs/mcs/anonymous.cs
mcs/mcs/ecore.cs

diff --git a/mcs/errors/cs0815-8.cs b/mcs/errors/cs0815-8.cs
new file mode 100644 (file)
index 0000000..31ed659
--- /dev/null
@@ -0,0 +1,13 @@
+// CS0815: An implicitly typed local variable declaration cannot be initialized with `anonymous method'
+// Line: 11
+
+using System;
+using System.Threading.Tasks;
+
+class X
+{
+       public static void Main ()
+       {
+               Task.Run(async () => { var a = async () => { }; Console.WriteLine(a); });
+       }
+}
\ No newline at end of file
index 12bf992bbcca22df81e61c6adde66b10d3216f3a..010418e470dc7d302d18501c3480ae023d4e12b7 100644 (file)
@@ -1188,6 +1188,9 @@ namespace Mono.CSharp {
                        if (compatibles.TryGetValue (type, out am))
                                return am;
 
+                       if (type == InternalType.ErrorType)
+                               return null;
+
                        TypeSpec delegate_type = CompatibleChecks (ec, type);
                        if (delegate_type == null)
                                return null;
index 5965fb53e9df360e4737c43d3af530192562317d..14d69f65acd341fb010d3d8bb0c9463847ed425b 100644 (file)
@@ -7600,6 +7600,7 @@ namespace Mono.CSharp {
                                ec.Report.Error (815, loc,
                                        "An implicitly typed local variable declaration cannot be initialized with `{0}'",
                                        type.GetSignatureForError ());
+                               type = InternalType.ErrorType;
                                return false;
                        }