Skip to content

Commit a580529

Browse files
eernstgcommit-bot@chromium.org
authored andcommitted
Adjusted Dart.g to contain the grammar updates of language repo PR 293
This CL makes several adjustments to the spec_parser grammar Dart.g, such that the spec_parser can parse the proposed NNBD constructs, cf. language PR #293. Change-Id: Ieec00259d73b6037d6a87d5c97cfac40186baef0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101500 Reviewed-by: Leaf Petersen <[email protected]> Commit-Queue: Erik Ernst <[email protected]>
1 parent 76c99bc commit a580529

11 files changed

+166
-57
lines changed

tests/language_2/abstract_syntax_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ main() {
1111

1212
class A {
1313
foo(); // //# 00: compile-time error
14-
static bar(); // //# 01: compile-time error
14+
static bar(); // //# 01: syntax error
1515
}
1616

1717
class B extends A {

tests/language_2/bad_constructor_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
// A constructor can't be static.
66
class A {
7-
static //# 00: compile-time error
7+
static //# 00: syntax error
88
A();
99
}
1010

tests/language_2/language_2_spec_parser.status

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const_native_factory_test: Skip # Uses `native`.
1313
deep_nesting_expression_test: Skip # JVM stack overflow.
1414
deep_nesting_statement_test: Skip # JVM stack overflow.
1515
double_invalid_test: Skip # Contains illegaly formatted double.
16+
extension_methods: Skip # Not yet supported.
1617
external_test/21: Fail # Test expects `runtime error`, it is a syntax error.
1718
getter_declaration_negative_test: Fail # Negative, uses getter with parameter.
1819
inst_field_initializer1_negative_test: Skip # Negative, not syntax.
@@ -34,7 +35,8 @@ map_literal_negative_test: Fail # Negative, uses `new Map<int>{..}`.
3435
new_expression1_negative_test: Fail # Negative, uses `new id`.
3536
new_expression2_negative_test: Fail # Negative, uses `new id(`.
3637
new_expression3_negative_test: Fail # Negative, uses `new id(...`.
37-
nnbd/*: Skip # Not yet included.
38+
nnbd/syntax/opt_out_nnbd_modifiers_test: Skip # Requires opt-out of NNBD.
39+
nnbd/syntax/pre_nnbd_modifiers_test: Skip # Requires opt-out of NNBD.
3840
no_such_method_negative_test: Skip # Negative, not syntax.
3941
non_const_super_negative_test: Skip # Negative, not syntax.
4042
operator1_negative_test: Fail # Negative, declares static operator.
@@ -65,4 +67,3 @@ test_negative_test: Fail # Negative, uses non-terminated string literal.
6567
unary_plus_negative_test: Fail # Negative, uses non-existing unary plus.
6668
vm/debug_break_enabled_vm_test/01: Fail # Uses debug break.
6769
vm/debug_break_enabled_vm_test/none: Fail # Uses debug break.
68-
void/void_type_function_types_test: Skip # Not yet supported.

tests/language_2/nnbd/static_errors/this_reference_in_late_field_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ void main() {
1111

1212
class C {
1313
var x = this; //# 00: compile-time error
14-
late x = this; //# 01: ok
14+
late var x = this; //# 01: ok
1515
}

tests/language_2/nnbd/static_errors/unchecked_use_of_nullable_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ void nullUses() async {
219219
_null + 4; //# 165: compile-time error
220220
-_null; //# 169: compile-time error
221221
_null++; //# 170: compile-time error
222-
++null; //# 171: compile-time error
222+
++_null; //# 171: compile-time error
223223
_null..isEven; //# 172: compile-time error
224224
_null[3]; //# 170: compile-time error
225225
_null[3] = 0; //# 171: compile-time error
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
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.
4+
5+
// SharedOptions=--enable-experiment=non-nullable
6+
7+
class A {
8+
static late x1; //# 01: syntax error
9+
static late final x2;
10+
static late int x3;
11+
static late final A x4;
12+
static late x5 = 0; //# 02: syntax error
13+
static late final x6 = 0;
14+
static late int x7 = 0;
15+
static late final A? x8 = null;
16+
17+
static final late x9; //# 03: syntax error
18+
static final late A x10; //# 04: syntax error
19+
static final late x11 = 0; //# 05: syntax error
20+
static final late A x12 = null; //# 06: syntax error
21+
22+
covariant late var x13;
23+
covariant late var x14 = '';
24+
covariant late x15; //# 07: syntax error
25+
covariant late x16 = ''; //# 08: syntax error
26+
27+
late covariant var x17; //# 09: syntax error
28+
late covariant var x18 = ''; //# 10: syntax error
29+
late covariant x19; //# 11: syntax error
30+
late covariant x20 = ''; //# 12: syntax error
31+
32+
covariant var late x21; //# 13: syntax error
33+
covariant var late x22 = ''; //# 14: syntax error
34+
35+
covariant late double x23;
36+
covariant late String x24 = '';
37+
38+
covariant double late x23; //# 15: syntax error
39+
covariant String late x24 = ''; //# 16: syntax error
40+
41+
late x25; //# 17: syntax error
42+
late final x26;
43+
late int x27;
44+
late final A x28;
45+
late x29 = 0; //# 18: syntax error
46+
late final x30 = 0;
47+
late int x31 = 0;
48+
late final A? x32 = null;
49+
50+
final late x33; //# 19: syntax error
51+
int late x34; //# 20: syntax error
52+
var late x35; //# 21: syntax error
53+
final late A x36; //# 22: syntax error
54+
final late x37 = 0; //# 23: syntax error
55+
int late x38 = 0; //# 24: syntax error
56+
var late x39 = 0; //# 25: syntax error
57+
final late A? x40 = null; //# 26: syntax error
58+
59+
List foo() {
60+
final x41 = true;
61+
late final x42;
62+
late final x43 = [], x44 = {};
63+
return x43;
64+
}
65+
}
66+
67+
abstract class B {
68+
m1(int some, regular, covariant parameters, {
69+
required p1,
70+
// required p2 = null, // Likely intended to be an error.
71+
required covariant p3,
72+
required covariant int p4,
73+
});
74+
}
75+
76+
main() {
77+
A? a;
78+
String? s = '';
79+
a?..foo().length..x27 = s!..toString().length;
80+
}

tests/language_2/nnbd/syntax/late_modifier_error_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77
// Invalid uses of "late" modifier
88

9-
late //# 01: compile-time error
9+
late //# 01: syntax error
1010
int f1(
1111
late //# 02: compile-time error
1212
int x
1313
) {}
1414

15-
late //# 03: compile-time error
15+
late //# 03: syntax error
1616
class C1 {
17-
late //# 04: compile-time error
17+
late //# 04: syntax error
1818
int m() {}
1919
}
2020

tests/language_2/nnbd/syntax/non_null_assertion_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,6 @@ main() {
7070
});
7171

7272
int i = 0;
73-
var x13 = [i++!]; // ignore: unnecessary_non_null_assertion
73+
var x13 = [(i++)!]; // ignore: unnecessary_non_null_assertion
7474
listOfObject = x13;
7575
}

tests/language_2/nnbd/syntax/nullable_type_error_test.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ main() {
1212
// The grammar for types does not allow multiple successive ? operators on a
1313
// type. Note: we test both with and without a space between `?`s because the
1414
// scanner treats `??` as a single token.
15-
int?? x1 = 0; //# 01: compile-time error
16-
core.int?? x2 = 0; //# 02: compile-time error
17-
List<int>?? x3 = <int>[]; //# 03: compile-time error
18-
void Function()?? x4 = f; //# 04: compile-time error
19-
int? ? x5 = 0; //# 05: compile-time error
20-
core.int? ? x6 = 0; //# 06: compile-time error
21-
List<int>? ? x7 = <int>[]; //# 07: compile-time error
22-
void Function()? ? x4 = f; //# 08: compile-time error
15+
int?? x1 = 0; //# 01: syntax error
16+
core.int?? x2 = 0; //# 02: syntax error
17+
List<int>?? x3 = <int>[]; //# 03: syntax error
18+
void Function()?? x4 = f; //# 04: syntax error
19+
int? ? x5 = 0; //# 05: syntax error
20+
core.int? ? x6 = 0; //# 06: syntax error
21+
List<int>? ? x7 = <int>[]; //# 07: syntax error
22+
void Function()? ? x4 = f; //# 08: syntax error
2323
}

tests/language_2/nnbd/syntax/required_modifier_error_test.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66

77
// Invalid uses of "required" modifier
88

9-
required //# 01: compile-time error
9+
required //# 01: syntax error
1010
int f1(
11-
required //# 02: compile-time error
11+
required //# 02: syntax error
1212
int x
1313
) {}
1414

15-
required //# 03: compile-time error
15+
required //# 03: syntax error
1616
class C1 {
17-
required //# 04: compile-time error
17+
required //# 04: syntax error
1818
int f2 = 0;
1919
}
2020

2121
// Duplicate modifier
2222
void f2({
2323
required
24-
required //# 05: compile-time error
24+
required //# 05: syntax error
2525
int i,
2626
}){
2727
}
@@ -30,8 +30,8 @@ void f2({
3030
class C2 {
3131
void m({
3232
required int i1,
33-
covariant required int i2, //# 07: compile-time error
34-
final required int i3, //# 08: compile-time error
33+
covariant required int i2, //# 07: syntax error
34+
final required int i3, //# 08: syntax error
3535
}) {
3636
}
3737
}

0 commit comments

Comments
 (0)