**** Merged from MCS ****
[mono-project.git] / mcs / errors / error-1.cs
blobfdea34ab79c16986be852eb4cee35c86b27c34ab
1 // This test must produce a compilation error in each method.
2 using System;
4 public class X
6 public static int Main ()
8 // This is a compilation-only test.
9 return 0;
12 // Must assign out parameter.
13 // CS0177
14 public static void test1 (out float f)
18 // Must assign it before returning.
19 public static void test2 (int a, out float f)
21 // CS0177
22 if (a == 5)
23 return;
25 f = 8.53F;
28 // CS0177
29 public static void test3 (out float f)
31 try {
32 f = 8.53F;
33 } catch {
34 return;
38 public static int test4 ()
40 int a;
42 try {
43 a = 3;
44 } catch {
45 Console.WriteLine ("EXCEPTION");
48 // CS0165
49 return a;
52 public static int test5 ()
54 int a;
56 try {
57 Console.WriteLine ("TRY");
58 a = 8;
59 } catch {
60 a = 9;
61 } finally {
62 // CS0165
63 Console.WriteLine (a);
66 return a;
69 public static void test6 (int a, out float f)
71 do {
72 // CS0177
73 if (a == 8) {
74 Console.WriteLine ("Hello");
75 return;
77 } while (false);
79 f = 1.3F;
80 return;
83 // CS0177
84 public static void test7 (out float f)
86 goto World;
87 // warning CS0162
88 f = 8.0F;
90 World: