diff options
author | Marek Safar <marek.safar@gmail.com> | 2017-06-05 13:19:08 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2017-06-05 13:23:06 +0300 |
commit | 51b93b6c23229e18f9e99db621ea3d733cee9f9d (patch) | |
tree | 0032ee4b233621e663a0293996ee61320f396773 /mcs/errors | |
parent | ed9fb93c62f03eb9ffde370edffafa8779e69ec1 (diff) |
[mcs] C#7 throw expression
Diffstat (limited to 'mcs/errors')
-rw-r--r-- | mcs/errors/cs0019-72.cs | 10 | ||||
-rw-r--r-- | mcs/errors/cs0155-5.cs | 7 | ||||
-rw-r--r-- | mcs/errors/cs0162-21.cs | 19 | ||||
-rw-r--r-- | mcs/errors/cs0173-6.cs | 10 | ||||
-rw-r--r-- | mcs/errors/cs0411-25.cs | 16 | ||||
-rw-r--r-- | mcs/errors/cs1061-18.cs | 18 | ||||
-rw-r--r-- | mcs/errors/cs1617.cs | 2 | ||||
-rw-r--r-- | mcs/errors/cs1644-51.cs | 8 | ||||
-rw-r--r-- | mcs/errors/cs4001-3.cs | 12 | ||||
-rw-r--r-- | mcs/errors/cs8188.cs | 13 |
10 files changed, 114 insertions, 1 deletions
diff --git a/mcs/errors/cs0019-72.cs b/mcs/errors/cs0019-72.cs new file mode 100644 index 00000000000..90cbae7ebdd --- /dev/null +++ b/mcs/errors/cs0019-72.cs @@ -0,0 +1,10 @@ +// CS0019: Operator `??' cannot be applied to operands of type `void' and `throw expression' +// Line: 20 + +class C +{ + public static void Main () + { + var s = Main () ?? throw null; + } +}
\ No newline at end of file diff --git a/mcs/errors/cs0155-5.cs b/mcs/errors/cs0155-5.cs new file mode 100644 index 00000000000..774700ab736 --- /dev/null +++ b/mcs/errors/cs0155-5.cs @@ -0,0 +1,7 @@ +// CS0155: The type caught or thrown must be derived from System.Exception +// Line: 9 + +class X +{ + public int Test () => throw ""; +} diff --git a/mcs/errors/cs0162-21.cs b/mcs/errors/cs0162-21.cs new file mode 100644 index 00000000000..e8bd4b2f79a --- /dev/null +++ b/mcs/errors/cs0162-21.cs @@ -0,0 +1,19 @@ +// CS0162: Unreachable code detected +// Line: 12 +// Compiler options: -warnaserror -warn:2 + +using System; + +class X +{ + void Test () + { + var x = true ? throw new NullReferenceException () : 1; + x = 2; + return; + } + + static void Main () + { + } +} diff --git a/mcs/errors/cs0173-6.cs b/mcs/errors/cs0173-6.cs new file mode 100644 index 00000000000..6c2dab2672b --- /dev/null +++ b/mcs/errors/cs0173-6.cs @@ -0,0 +1,10 @@ +// CS0173: Type of conditional expression cannot be determined because there is no implicit conversion between `throw expression' and `throw expression' +// Line: 8 + +class C +{ + public static void Test (bool b) + { + var s = b ? throw null : throw null; + } +}
\ No newline at end of file diff --git a/mcs/errors/cs0411-25.cs b/mcs/errors/cs0411-25.cs new file mode 100644 index 00000000000..c7f92fb96d7 --- /dev/null +++ b/mcs/errors/cs0411-25.cs @@ -0,0 +1,16 @@ +// CS0411: The type arguments for method `C.Foo<T>(System.Func<T>)' cannot be inferred from the usage. Try specifying the type arguments explicitly +// Line: 10 + +using System; + +public class C +{ + public static void Main () + { + Foo (() => throw null); + } + + static void Foo<T> (Func<T> arg) + { + } +}
\ No newline at end of file diff --git a/mcs/errors/cs1061-18.cs b/mcs/errors/cs1061-18.cs new file mode 100644 index 00000000000..1f201d5320b --- /dev/null +++ b/mcs/errors/cs1061-18.cs @@ -0,0 +1,18 @@ +// CS1061: No overload for method `Call' takes `0' arguments +// Line: 11 + +using System; + +class Program +{ + static void Main () + { + Action<dynamic, object> action = delegate { }; + Foo (action).NoDynamicBinding (); + } + + static T Foo<T>(Action<T, T> x) + { + throw new NotImplementedException (); + } +}
\ No newline at end of file diff --git a/mcs/errors/cs1617.cs b/mcs/errors/cs1617.cs index 88f9c12deca..cfa63a7d835 100644 --- a/mcs/errors/cs1617.cs +++ b/mcs/errors/cs1617.cs @@ -1,3 +1,3 @@ -// CS1617: Invalid -langversion option `ISO'. It must be `ISO-1', `ISO-2', Default or value in range 1 to 6 +// CS1617: Invalid -langversion option `ISO'. It must be `ISO-1', `ISO-2', Default or value in range 1 to 7 // Line: 0 // Compiler options: -langversion:ISO diff --git a/mcs/errors/cs1644-51.cs b/mcs/errors/cs1644-51.cs new file mode 100644 index 00000000000..0cc61504e6f --- /dev/null +++ b/mcs/errors/cs1644-51.cs @@ -0,0 +1,8 @@ +// CS1644: Feature `throw expression' cannot be used because it is not part of the C# 6.0 language specification +// Line: 5 +// Compiler options: -langversion:6 + +static class Class +{ + int Prop => throw null; +} diff --git a/mcs/errors/cs4001-3.cs b/mcs/errors/cs4001-3.cs new file mode 100644 index 00000000000..9f4d82c66bb --- /dev/null +++ b/mcs/errors/cs4001-3.cs @@ -0,0 +1,12 @@ +// CS4001: Cannot await `void' expression +// Line: 10 + +using System; + +class A +{ + static async void Test () + { + await Console.WriteLine; + } +} diff --git a/mcs/errors/cs8188.cs b/mcs/errors/cs8188.cs new file mode 100644 index 00000000000..d2f225fec5f --- /dev/null +++ b/mcs/errors/cs8188.cs @@ -0,0 +1,13 @@ +// CS8188: An expression tree cannot not contain a throw expression +// Line: 11 + +using System; +using System.Linq.Expressions; + +class C +{ + public static void Main () + { + Expression<Func<object>> l = () => throw null; + } +}
\ No newline at end of file |