OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 // Test to detect syntactically illegal left-hand-side (assignable) | 5 // Test to detect syntactically illegal left-hand-side (assignable) |
6 // expressions. | 6 // expressions. |
7 | 7 |
8 class C { | 8 class C { |
9 static var static_field = 0; | 9 static var static_field = 0; |
10 } | 10 } |
11 | 11 |
12 var tl_static_var = 0; | 12 var tl_static_var = 0; |
13 | 13 |
14 main() { | 14 main() { |
15 tl_static_var = 0; | 15 tl_static_var = 0; |
16 (tl_static_var) = 0; /// 01: compile-time error | 16 (tl_static_var) = 0; //# 01: compile-time error |
17 (tl_static_var)++; /// 02: compile-time error | 17 (tl_static_var)++; //# 02: compile-time error |
18 ++(tl_static_var); /// 03: compile-time error | 18 ++(tl_static_var); //# 03: compile-time error |
19 | 19 |
20 C.static_field = 0; | 20 C.static_field = 0; |
21 (C.static_field) = 0; /// 11: compile-time error | 21 (C.static_field) = 0; //# 11: compile-time error |
22 (C.static_field)++; /// 12: compile-time error | 22 (C.static_field)++; //# 12: compile-time error |
23 ++(C.static_field); /// 13: compile-time error | 23 ++(C.static_field); //# 13: compile-time error |
24 | 24 |
25 tl_static_var = [1, 2, 3]; | 25 tl_static_var = [1, 2, 3]; |
26 tl_static_var[0] = 0; | 26 tl_static_var[0] = 0; |
27 (tl_static_var)[0] = 0; | 27 (tl_static_var)[0] = 0; |
28 (tl_static_var[0]) = 0; /// 21: compile-time error | 28 (tl_static_var[0]) = 0; //# 21: compile-time error |
29 (tl_static_var[0])++; /// 22: compile-time error | 29 (tl_static_var[0])++; //# 22: compile-time error |
30 ++(tl_static_var[0]); /// 23: compile-time error | 30 ++(tl_static_var[0]); //# 23: compile-time error |
31 | 31 |
32 C.static_field = [1, 2, 3]; | 32 C.static_field = [1, 2, 3]; |
33 (C.static_field[0]) = 0; /// 31: compile-time error | 33 (C.static_field[0]) = 0; //# 31: compile-time error |
34 (C.static_field[0])++; /// 32: compile-time error | 34 (C.static_field[0])++; //# 32: compile-time error |
35 ++(C.static_field[0]); /// 33: compile-time error | 35 ++(C.static_field[0]); //# 33: compile-time error |
36 | 36 |
37 var a = 0; | 37 var a = 0; |
38 (a) = 0; /// 41: compile-time error | 38 (a) = 0; //# 41: compile-time error |
39 (a)++; /// 42: compile-time error | 39 (a)++; //# 42: compile-time error |
40 ++(a); /// 43: compile-time error | 40 ++(a); //# 43: compile-time error |
41 | 41 |
42 // Neat palindrome expression. x is assignable, ((x)) is not. | 42 // Neat palindrome expression. x is assignable, ((x)) is not. |
43 var funcnuf = (x) => ((x))=((x)) <= (x); /// 50: compile-time error | 43 var funcnuf = (x) => ((x))=((x)) <= (x); //# 50: compile-time error |
44 } | 44 } |
OLD | NEW |