diff options
author | Marek Safar <marek.safar@gmail.com> | 2017-06-30 20:44:41 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2017-06-30 20:47:06 +0300 |
commit | d2a26c959578e8d721cfe320f6ac1d8ee8633cf3 (patch) | |
tree | 7cd550c5949e7044133470707233c7a01fd14cd8 /mcs/errors | |
parent | bb99b3ef99e38cdbc8fbcab61d62a2943e216b61 (diff) |
[mcs] C# 7 tuple (foundation only).
Still couple of advanced features not implemented and parser cannot
deal with unnamed tuple type at type declaration level.
Diffstat (limited to 'mcs/errors')
36 files changed, 385 insertions, 5 deletions
diff --git a/mcs/errors/cs0029-38.cs b/mcs/errors/cs0029-38.cs new file mode 100644 index 00000000000..6ee7146f496 --- /dev/null +++ b/mcs/errors/cs0029-38.cs @@ -0,0 +1,10 @@ +// CS0029: Cannot implicitly convert type `int' to `(long, bool)' +// Line: 8 + +class C +{ + static void Test () + { + System.ValueTuple<long, bool> arg = 1; + } +} diff --git a/mcs/errors/cs0815-7.cs b/mcs/errors/cs0815-7.cs new file mode 100644 index 00000000000..38c3ff3a3f0 --- /dev/null +++ b/mcs/errors/cs0815-7.cs @@ -0,0 +1,10 @@ +// CS0815: An implicitly typed local variable declaration cannot be initialized with `(int, method group)' +// Line: 8 + +class XX +{ + public static void Main () + { + var m = (1, Main); + } +}
\ No newline at end of file diff --git a/mcs/errors/cs0826-11.cs b/mcs/errors/cs0826-11.cs new file mode 100644 index 00000000000..55d04caf1d8 --- /dev/null +++ b/mcs/errors/cs0826-11.cs @@ -0,0 +1,10 @@ +// CS0826: The type of an implicitly typed array cannot be inferred from the initializer. Try specifying array type explicitly +// Line: 8 + +class XX +{ + public static void Main () + { + var m = new [] { (1, Main) }; + } +}
\ No newline at end of file diff --git a/mcs/errors/cs0828-7.cs b/mcs/errors/cs0828-7.cs new file mode 100644 index 00000000000..c60a2618e6f --- /dev/null +++ b/mcs/errors/cs0828-7.cs @@ -0,0 +1,12 @@ +// CS0827: An anonymous type property `Prop' cannot be initialized with `(int, method group)' +// Line: 9 + +class XX +{ + public static void Main () + { + var m = new { + Prop = (1, Main) + }; + } +}
\ No newline at end of file diff --git a/mcs/errors/cs1525-12.cs b/mcs/errors/cs1525-12.cs index a3b2eee19b6..47b4b4412a2 100644 --- a/mcs/errors/cs1525-12.cs +++ b/mcs/errors/cs1525-12.cs @@ -1,4 +1,4 @@ -// CS1525: Unexpected symbol `==', expecting `type' +// CS1525: Unexpected symbol `==', expecting `(' or `type' // Line: 8 class A diff --git a/mcs/errors/cs1525-40.cs b/mcs/errors/cs1525-40.cs index f7bac981094..297018f16bb 100644 --- a/mcs/errors/cs1525-40.cs +++ b/mcs/errors/cs1525-40.cs @@ -1,4 +1,4 @@ -// CS1525: Unexpected symbol `1', expecting `type' +// CS1525: Unexpected symbol `1', expecting `(' or `type' // Line: 4 class M : 1 diff --git a/mcs/errors/cs1525-43.cs b/mcs/errors/cs1525-43.cs index a43ae1ddb0a..d83d4d847fa 100644 --- a/mcs/errors/cs1525-43.cs +++ b/mcs/errors/cs1525-43.cs @@ -1,4 +1,4 @@ -// CS1525: Unexpected symbol `)', expecting `[', `out', `params', `ref', `this', or `type' +// CS1525: Unexpected symbol `)', expecting `(', `[', `out', `params', `ref', `this', or `type' // Line: 6 class TestClass diff --git a/mcs/errors/cs1026-2.cs b/mcs/errors/cs1525-57.cs index 45dfd738549..4dd717ab5de 100644 --- a/mcs/errors/cs1026-2.cs +++ b/mcs/errors/cs1525-57.cs @@ -1,4 +1,4 @@ -// CS1026: Unexpected symbol `;', expecting `)' +// CS1026: Unexpected symbol `;', expecting `)' or `,' // Line: 10 using System; diff --git a/mcs/errors/cs1525-7.cs b/mcs/errors/cs1525-7.cs index 9ac639029fd..f28fd8ac7fa 100644 --- a/mcs/errors/cs1525-7.cs +++ b/mcs/errors/cs1525-7.cs @@ -1,4 +1,4 @@ -// CS1525: Unexpected symbol `this', expecting `[', `{', or `type' +// CS1525: Unexpected symbol `this', expecting `(', `[', `{', or `type' // Line: 8 class M diff --git a/mcs/errors/cs1644-53.cs b/mcs/errors/cs1644-53.cs new file mode 100644 index 00000000000..2c66dd064b3 --- /dev/null +++ b/mcs/errors/cs1644-53.cs @@ -0,0 +1,11 @@ +// CS1644: Feature `tuples' cannot be used because it is not part of the C# 6.0 language specification +// Line: 7 +// Compiler options: -langversion:6 + +class Class +{ + static (int, bool) Foo () + { + return; + } +} diff --git a/mcs/errors/cs1644-54.cs b/mcs/errors/cs1644-54.cs new file mode 100644 index 00000000000..53d70f9d563 --- /dev/null +++ b/mcs/errors/cs1644-54.cs @@ -0,0 +1,11 @@ +// CS1644: Feature `tuples' cannot be used because it is not part of the C# 6.0 language specification +// Line: 9 +// Compiler options: -langversion:6 + +class Class +{ + static void Main () + { + var t = (a: 1, b: 2); + } +} diff --git a/mcs/errors/cs8123-2.cs b/mcs/errors/cs8123-2.cs new file mode 100644 index 00000000000..4fe11eebc35 --- /dev/null +++ b/mcs/errors/cs8123-2.cs @@ -0,0 +1,11 @@ +// CS8123: The tuple element name `a' is ignored because a different name or no name is specified by the target type `(int, int)' +// Line: 9 +// Compiler options: -warnaserror + +class C +{ + public static void Main () + { + (int tt1, int tt2) t = (a: 1, 2); + } +}
\ No newline at end of file diff --git a/mcs/errors/cs8123.cs b/mcs/errors/cs8123.cs new file mode 100644 index 00000000000..cf446b29ecd --- /dev/null +++ b/mcs/errors/cs8123.cs @@ -0,0 +1,11 @@ +// CS8123: The tuple element name `b' is ignored because a different name or no name is specified by the target type `(long, string)' +// Line: 9 +// Compiler options: -warnaserror + +static class X +{ + static (long a, string x) Test () + { + return (b: 1, ""); + } +}
\ No newline at end of file diff --git a/mcs/errors/cs8124.cs b/mcs/errors/cs8124.cs new file mode 100644 index 00000000000..d7d04160b84 --- /dev/null +++ b/mcs/errors/cs8124.cs @@ -0,0 +1,9 @@ +// CS8124: Tuple must contain at least two elements +// Line: 6 + +class X +{ + static (int) Foo () + { + } +}
\ No newline at end of file diff --git a/mcs/errors/cs8125.cs b/mcs/errors/cs8125.cs new file mode 100644 index 00000000000..bd45e5948a8 --- /dev/null +++ b/mcs/errors/cs8125.cs @@ -0,0 +1,9 @@ +// CS8125: The tuple element name `Item22' can only be used at position 22 +// Line: 6 + +class C +{ + static void Test ((int Item22, int b) arg) + { + } +} diff --git a/mcs/errors/cs8126.cs b/mcs/errors/cs8126.cs new file mode 100644 index 00000000000..67f4020bcf2 --- /dev/null +++ b/mcs/errors/cs8126.cs @@ -0,0 +1,9 @@ +// CS8126: The tuple element name `Rest' is reserved +// Line: 6 + +class C +{ + static void Test ((int Rest, int b) arg) + { + } +} diff --git a/mcs/errors/cs8127.cs b/mcs/errors/cs8127.cs new file mode 100644 index 00000000000..319dbf67e71 --- /dev/null +++ b/mcs/errors/cs8127.cs @@ -0,0 +1,10 @@ +// CS8127: The tuple element name `a' is a duplicate +// Line: 6 + +class C +{ + static (int a, int a) Test () + { + return null; + } +} diff --git a/mcs/errors/cs8129.cs b/mcs/errors/cs8129.cs new file mode 100644 index 00000000000..be6781b3b6b --- /dev/null +++ b/mcs/errors/cs8129.cs @@ -0,0 +1,20 @@ +// CS8129: +// Line: + +using System; + +class C +{ + static void Main () + { + long x; + string y; + (x, y) = new C (); + } + + public static void Deconstruct (out int a, out string b) + { + a = 1; + b = "hello"; + } +}
\ No newline at end of file diff --git a/mcs/errors/cs8131.cs b/mcs/errors/cs8131.cs new file mode 100644 index 00000000000..362c5916c89 --- /dev/null +++ b/mcs/errors/cs8131.cs @@ -0,0 +1,11 @@ +// CS8131: Deconstruct assignment requires an expression with a type on the right-hand-side +// Line: 9 + +class C +{ + public static void Main () + { + int x, y; + (x, y) = null; + } +}
\ No newline at end of file diff --git a/mcs/errors/cs8132.cs b/mcs/errors/cs8132.cs new file mode 100644 index 00000000000..be9e522aec4 --- /dev/null +++ b/mcs/errors/cs8132.cs @@ -0,0 +1,10 @@ +// CS8132: +// Line: 8 + +class C +{ + public static void Main () + { + var (t, u, v) = (1, 2); + } +}
\ No newline at end of file diff --git a/mcs/errors/cs8133.cs b/mcs/errors/cs8133.cs new file mode 100644 index 00000000000..0c7812590b5 --- /dev/null +++ b/mcs/errors/cs8133.cs @@ -0,0 +1,11 @@ +// CS8133: Cannot deconstruct dynamic objects +// Line: 9 + +class C +{ + public static void Test (dynamic d) + { + int x, y; + (x, y) = d; + } +}
\ No newline at end of file diff --git a/mcs/errors/cs8135.cs b/mcs/errors/cs8135.cs new file mode 100644 index 00000000000..797bcf5fece --- /dev/null +++ b/mcs/errors/cs8135.cs @@ -0,0 +1,10 @@ +// CS8135: Tuple literal `(int, method group)' cannot be converted to type `object' +// Line: 8 + +class XX +{ + public static void Main () + { + object m = (1, Main); + } +}
\ No newline at end of file diff --git a/mcs/errors/cs8138.cs b/mcs/errors/cs8138.cs new file mode 100644 index 00000000000..f870b72962b --- /dev/null +++ b/mcs/errors/cs8138.cs @@ -0,0 +1,10 @@ +// CS8138: Do not use `System.Runtime.CompilerServices.TupleElementNamesAttribute' directly. Use the tuple syntax instead +// Line: 7 + +using System; +using System.Runtime.CompilerServices; + +[TupleElementNames (new[] { "a", "b" })] +public class C +{ +} diff --git a/mcs/errors/cs8139-2.cs b/mcs/errors/cs8139-2.cs new file mode 100644 index 00000000000..93ff00563f7 --- /dev/null +++ b/mcs/errors/cs8139-2.cs @@ -0,0 +1,18 @@ +// CS8139: `D.M()': cannot change return type tuple element names when overriding inherited member `C.M()' +// Line: 14 + +class C +{ + public virtual (int a, int b) M () + { + throw null; + } +} + +class D : C +{ + public override (int, int) M () + { + throw null; + } +}
\ No newline at end of file diff --git a/mcs/errors/cs8139-3.cs b/mcs/errors/cs8139-3.cs new file mode 100644 index 00000000000..247a0d1c302 --- /dev/null +++ b/mcs/errors/cs8139-3.cs @@ -0,0 +1,16 @@ +// CS8139: `D.M((int, int))': cannot change tuple element names when overriding inherited member `C.M((int, int))' +// Line: 13 + +class C +{ + public virtual void M ((int, int) arg) + { + } +} + +class D : C +{ + public override void M ((int c, int d) arg) + { + } +}
\ No newline at end of file diff --git a/mcs/errors/cs8139-4.cs b/mcs/errors/cs8139-4.cs new file mode 100644 index 00000000000..8272a5d4706 --- /dev/null +++ b/mcs/errors/cs8139-4.cs @@ -0,0 +1,20 @@ +// CS8139: `D.Prop': cannot change return type tuple element names when overriding inherited member `C.Prop' +// Line: 14 + +class C +{ + public virtual (int a, int b) Prop { + get { + throw null; + } + } +} + +class D : C +{ + public override (int c, int d) Prop { + get { + throw null; + } + } +}
\ No newline at end of file diff --git a/mcs/errors/cs8139.cs b/mcs/errors/cs8139.cs new file mode 100644 index 00000000000..cb496616a45 --- /dev/null +++ b/mcs/errors/cs8139.cs @@ -0,0 +1,18 @@ +// CS8139: `D.M()': cannot change return type tuple element names when overriding inherited member `C.M()' +// Line: 14 + +class C +{ + public virtual (int a, int b) M () + { + throw null; + } +} + +class D : C +{ + public override (int c, int d) M () + { + throw null; + } +}
\ No newline at end of file diff --git a/mcs/errors/cs8141-2.cs b/mcs/errors/cs8141-2.cs new file mode 100644 index 00000000000..42c80cea0cd --- /dev/null +++ b/mcs/errors/cs8141-2.cs @@ -0,0 +1,19 @@ +// CS8141: +// Line: 11 + +public interface I<T> +{ + int this[T arg] { get; set; } +} + +public class C : I<(int a, int b)> +{ + public int this[(int c, int d) arg] { + get { + return 1; + } + set { + + } + } +} diff --git a/mcs/errors/cs8141.cs b/mcs/errors/cs8141.cs new file mode 100644 index 00000000000..fd3c05f57f1 --- /dev/null +++ b/mcs/errors/cs8141.cs @@ -0,0 +1,15 @@ +// CS8141: +// Line: 9 + +public interface I<T> +{ + T Test (); +} + +public class C : I<(int a, int b)> +{ + public (int c, int d) Test () + { + return (1, 2); + } +} diff --git a/mcs/errors/cs8142.cs b/mcs/errors/cs8142.cs new file mode 100644 index 00000000000..3a9fd3570d8 --- /dev/null +++ b/mcs/errors/cs8142.cs @@ -0,0 +1,14 @@ +// CS8142: A partial method declaration and partial method implementation must both use the same tuple element names +// Line: 11 + +partial class X +{ + partial void Foo ((int a, int b) arg); +} + +partial class X +{ + partial void Foo ((int c, int d) arg) + { + } +}
\ No newline at end of file diff --git a/mcs/errors/cs8143.cs b/mcs/errors/cs8143.cs new file mode 100644 index 00000000000..19064cdea1a --- /dev/null +++ b/mcs/errors/cs8143.cs @@ -0,0 +1,13 @@ +// CS8143: An expression tree cannot contain a tuple literal +// Line: 11 + +using System; +using System.Linq.Expressions; + +class C +{ + public static void Main () + { + Expression<Func<object>> l = () => (-1, 2); + } +}
\ No newline at end of file diff --git a/mcs/errors/cs8144.cs b/mcs/errors/cs8144.cs new file mode 100644 index 00000000000..4a5cc52b59c --- /dev/null +++ b/mcs/errors/cs8144.cs @@ -0,0 +1,14 @@ +// CS8144: +// Line: 12 + +using System; +using System.Linq.Expressions; + +class X +{ + public static void Main () + { + (byte b, short d) t = (0, 0); + Expression<Func<(int a, int aa)>> e = () => t; + } +} diff --git a/mcs/errors/cs8181.cs b/mcs/errors/cs8181.cs new file mode 100644 index 00000000000..523d168faad --- /dev/null +++ b/mcs/errors/cs8181.cs @@ -0,0 +1,12 @@ +// CS8181: Tuple type cannot be used in an object creation expression. Use a tuple literal expression instead +// Line: 8 + +class C +{ + static void Main () + { + var x = new (long, int) () { + Item1 = 1 + }; + } +} diff --git a/mcs/errors/cs8210.cs b/mcs/errors/cs8210.cs new file mode 100644 index 00000000000..a297dc78082 --- /dev/null +++ b/mcs/errors/cs8210.cs @@ -0,0 +1,10 @@ +// CS8210: A tuple literal cannot not contain a value of type `void' +// Line: 8 + +class XX +{ + public static void Main () + { + var m = (1, Main ()); + } +}
\ No newline at end of file diff --git a/mcs/errors/cs8307.cs b/mcs/errors/cs8307.cs new file mode 100644 index 00000000000..6772f50aa94 --- /dev/null +++ b/mcs/errors/cs8307.cs @@ -0,0 +1,10 @@ +// CS8307: The first operand of an `as' operator may not be a tuple literal without a natural type +// Line: 8 + +class X +{ + public static void Main () + { + var g = (1, Main) as object; + } +}
\ No newline at end of file diff --git a/mcs/errors/known-issues-net_4_x b/mcs/errors/known-issues-net_4_x index 1e07f7c667e..9282fd4adb9 100644 --- a/mcs/errors/known-issues-net_4_x +++ b/mcs/errors/known-issues-net_4_x @@ -17,3 +17,9 @@ cs0080.cs # Operators cs0457-2.cs cs0457.cs + +cs8129.cs NO ERROR +cs8132.cs NO ERROR +cs8141.cs +cs8141-2.cs +cs8144.cs |