Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 | 6 |
| 7 void checkBadSymbol(String s) { | 7 void checkBadSymbol(String s) { |
| 8 Expect.throws(() => new Symbol(s), (e) => e is ArgumentError); | 8 Expect.throws(() => new Symbol(s), (e) => e is ArgumentError); |
| 9 } | 9 } |
| 10 | 10 |
| 11 main() { | 11 main() { |
| 12 var x; | 12 var x; |
| 13 | 13 |
| 14 // 'void' is allowed as a symbol name. | 14 // 'void' is allowed as a symbol name. |
| 15 x = const Symbol('void'); /// 01: ok | 15 x = const Symbol('void'); /// 01: ok |
| 16 x = #void; /// 02: ok | 16 x = #void; /// 02: ok |
| 17 x = new Symbol('void'); /// 03: ok | 17 x = new Symbol('void'); /// 03: ok |
| 18 | 18 |
| 19 // However, it is not allowed as a part of a symbol name. | 19 // However, it is not allowed as a part of a symbol name. |
| 20 x = const Symbol('void.foo'); /// 04: compile-time error | 20 x = const Symbol('void.foo'); /// 04: compile-time error |
| 21 x = #void.foo; /// 05: compile-time error | 21 x = #void.foo; /// 05: static type warning |
|
ahe
2017/04/05 20:04:14
What is supposed to happen when this line is execu
Paul Berry
2017/04/05 20:29:28
It should be equivalent to:
x = (#void).foo;
So
ahe
2017/04/06 10:55:52
Thank you for the details. Based on them, I've cha
Paul Berry
2017/04/06 17:20:55
Sounds reasonable. Thanks!
| |
| 22 checkBadSymbol('void.foo'); /// 06: ok | 22 checkBadSymbol('void.foo'); /// 06: ok |
| 23 x = const Symbol('foo.void'); /// 07: compile-time error | 23 x = const Symbol('foo.void'); /// 07: compile-time error |
| 24 x = #foo.void; /// 08: compile-time error | 24 x = #foo.void; /// 08: compile-time error |
| 25 checkBadSymbol('foo.void'); /// 09: ok | 25 checkBadSymbol('foo.void'); /// 09: ok |
| 26 | 26 |
| 27 // All other reserved words are disallowed. | 27 // All other reserved words are disallowed. |
| 28 x = const Symbol('assert'); /// 10: compile-time error | 28 x = const Symbol('assert'); /// 10: compile-time error |
| 29 x = const Symbol('break'); /// 10: continued | 29 x = const Symbol('break'); /// 10: continued |
| 30 x = const Symbol('case'); /// 10: continued | 30 x = const Symbol('case'); /// 10: continued |
| 31 x = const Symbol('catch'); /// 10: continued | 31 x = const Symbol('catch'); /// 10: continued |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 checkBadSymbol('super'); /// 12: continued | 115 checkBadSymbol('super'); /// 12: continued |
| 116 checkBadSymbol('switch'); /// 12: continued | 116 checkBadSymbol('switch'); /// 12: continued |
| 117 checkBadSymbol('this'); /// 12: continued | 117 checkBadSymbol('this'); /// 12: continued |
| 118 checkBadSymbol('throw'); /// 12: continued | 118 checkBadSymbol('throw'); /// 12: continued |
| 119 checkBadSymbol('true'); /// 12: continued | 119 checkBadSymbol('true'); /// 12: continued |
| 120 checkBadSymbol('try'); /// 12: continued | 120 checkBadSymbol('try'); /// 12: continued |
| 121 checkBadSymbol('var'); /// 12: continued | 121 checkBadSymbol('var'); /// 12: continued |
| 122 checkBadSymbol('while'); /// 12: continued | 122 checkBadSymbol('while'); /// 12: continued |
| 123 checkBadSymbol('with'); /// 12: continued | 123 checkBadSymbol('with'); /// 12: continued |
| 124 } | 124 } |
| OLD | NEW |