Skip to content

Commit 30e21f3

Browse files
jensjohacommit-bot@chromium.org
authored andcommitted
Don't crash when additional exports contain duplicate names
Fixes #36647 Change-Id: I45019b2113fde5bcd1f5e4227f7a1d86c570001f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100645 Reviewed-by: Kevin Millikin <[email protected]> Commit-Queue: Jens Johansen <[email protected]>
1 parent 9670b2c commit 30e21f3

20 files changed

+659
-1
lines changed

pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,13 @@ class KernelLibraryBuilder
13821382
unserializableExports ??= <String, String>{};
13831383
unserializableExports[name] = member.message.message;
13841384
} else {
1385-
library.additionalExports.add(member.target.reference);
1385+
// Eventually (in #buildBuilder) members aren't added to the
1386+
// library if the have 'next' pointers, so don't add them as
1387+
// additionalExports either. Add the last one only (the one that
1388+
// will eventually be added to the library).
1389+
Declaration memberLast = member;
1390+
while (memberLast.next != null) memberLast = memberLast.next;
1391+
library.additionalExports.add(memberLast.target.reference);
13861392
}
13871393
}
13881394
}

pkg/front_end/testcases/legacy.status

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ regress/issue_35259: RuntimeError # Expected
115115
regress/issue_35260: RuntimeError # Expected
116116
regress/issue_35266: RuntimeError # Expected
117117
regress/issue_36400: RuntimeError
118+
regress/issue_36647: RuntimeError # Expected
119+
regress/issue_36647_2: RuntimeError # Expected
118120
reject_generic_function_types_in_bounds: RuntimeError # Expected
119121
runtime_checks/implicit_downcast_constructor_initializer: RuntimeError # Test exercises strong mode semantics
120122
runtime_checks/implicit_downcast_do: RuntimeError # Test exercises strong mode semantics
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
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+
import 'issue_36647_lib1.dart';
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Object:
2+
superclasses:
3+
interfaces:
4+
classMembers:
5+
Object._haveSameRuntimeType
6+
Object.toString
7+
Object.runtimeType
8+
Object._toString
9+
Object._simpleInstanceOf
10+
Object._hashCodeRnd
11+
Object._instanceOf
12+
Object.noSuchMethod
13+
Object._objectHashCode
14+
Object._identityHashCode
15+
Object.hashCode
16+
Object._simpleInstanceOfFalse
17+
Object._simpleInstanceOfTrue
18+
Object.==
19+
classSetters:
20+
21+
xxx:
22+
superclasses:
23+
Object
24+
interfaces:
25+
classMembers:
26+
Object.toString
27+
Object.runtimeType
28+
Object._simpleInstanceOf
29+
Object._instanceOf
30+
Object.noSuchMethod
31+
Object._identityHashCode
32+
Object.hashCode
33+
Object._simpleInstanceOfFalse
34+
Object._simpleInstanceOfTrue
35+
Object.==
36+
classSetters:
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
library;
2+
import self as self;
3+
4+
import "org-dartlang-testcase:///issue_36647_lib1.dart";
5+
6+
7+
library;
8+
import self as self2;
9+
import "issue_36647_lib2.dart" as iss;
10+
additionalExports = (iss::xxx)
11+
, iss::XXX)
12+
, iss::extends)
13+
14+
15+
export "org-dartlang-testcase:///issue_36647_lib2.dart";
16+
17+
18+
library;
19+
//
20+
// Problems in library:
21+
//
22+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:11: Error: Expected a class or mixin body, but got 'xx'.
23+
// class xxx xx XXX extends XXX {
24+
// ^^
25+
//
26+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:14: Error: Expected ';' after this.
27+
// class xxx xx XXX extends XXX {
28+
// ^^^
29+
//
30+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:18: Error: Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
31+
// Try adding the name of the type of the variable or the keyword 'var'.
32+
// class xxx xx XXX extends XXX {
33+
// ^^^^^^^
34+
//
35+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:18: Error: Expected an identifier, but got 'extends'.
36+
// class xxx xx XXX extends XXX {
37+
// ^^^^^^^
38+
//
39+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:18: Error: Expected ';' after this.
40+
// class xxx xx XXX extends XXX {
41+
// ^^^^^^^
42+
//
43+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:26: Error: A function declaration needs an explicit list of parameters.
44+
// Try adding a parameter list to the function declaration.
45+
// class xxx xx XXX extends XXX {
46+
// ^^^
47+
//
48+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:26: Error: 'XXX' is already declared in this scope.
49+
// class xxx xx XXX extends XXX {
50+
// ^^^
51+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:14: Context: Previous declaration of 'XXX'.
52+
// class xxx xx XXX extends XXX {
53+
// ^^^
54+
//
55+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:11: Warning: Type 'xx' not found.
56+
// class xxx xx XXX extends XXX {
57+
// ^^
58+
//
59+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:11: Warning: 'xx' isn't a type.
60+
// class xxx xx XXX extends XXX {
61+
// ^^
62+
//
63+
import self as iss;
64+
import "dart:core" as core;
65+
66+
class xxx extends core::Object {
67+
synthetic constructor •() → iss::xxx
68+
: super core::Object::•()
69+
;
70+
}
71+
static field invalid-type XXX;
72+
static field dynamic extends;
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
library;
2+
import self as self;
3+
4+
import "org-dartlang-testcase:///issue_36647_lib1.dart";
5+
6+
7+
library;
8+
import self as self2;
9+
import "issue_36647_lib2.dart" as iss;
10+
additionalExports = (iss::xxx)
11+
, iss::XXX)
12+
, iss::extends)
13+
14+
15+
export "org-dartlang-testcase:///issue_36647_lib2.dart";
16+
17+
18+
library;
19+
//
20+
// Problems in library:
21+
//
22+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:11: Error: Expected a class or mixin body, but got 'xx'.
23+
// class xxx xx XXX extends XXX {
24+
// ^^
25+
//
26+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:14: Error: Expected ';' after this.
27+
// class xxx xx XXX extends XXX {
28+
// ^^^
29+
//
30+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:18: Error: Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
31+
// Try adding the name of the type of the variable or the keyword 'var'.
32+
// class xxx xx XXX extends XXX {
33+
// ^^^^^^^
34+
//
35+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:18: Error: Expected an identifier, but got 'extends'.
36+
// class xxx xx XXX extends XXX {
37+
// ^^^^^^^
38+
//
39+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:18: Error: Expected ';' after this.
40+
// class xxx xx XXX extends XXX {
41+
// ^^^^^^^
42+
//
43+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:26: Error: A function declaration needs an explicit list of parameters.
44+
// Try adding a parameter list to the function declaration.
45+
// class xxx xx XXX extends XXX {
46+
// ^^^
47+
//
48+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:26: Error: 'XXX' is already declared in this scope.
49+
// class xxx xx XXX extends XXX {
50+
// ^^^
51+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:14: Context: Previous declaration of 'XXX'.
52+
// class xxx xx XXX extends XXX {
53+
// ^^^
54+
//
55+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:11: Warning: Type 'xx' not found.
56+
// class xxx xx XXX extends XXX {
57+
// ^^
58+
//
59+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:11: Warning: 'xx' isn't a type.
60+
// class xxx xx XXX extends XXX {
61+
// ^^
62+
//
63+
import self as iss;
64+
import "dart:core" as core;
65+
66+
class xxx extends core::Object {
67+
synthetic constructor •() → iss::xxx
68+
: super core::Object::•()
69+
;
70+
}
71+
static field invalid-type XXX;
72+
static field dynamic extends;
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
library;
2+
import self as self;
3+
4+
import "org-dartlang-testcase:///issue_36647_lib1.dart";
5+
6+
7+
library;
8+
import self as self2;
9+
import "issue_36647_lib2.dart" as iss;
10+
additionalExports = (iss::xxx)
11+
, iss::XXX)
12+
, iss::extends)
13+
14+
15+
export "org-dartlang-testcase:///issue_36647_lib2.dart";
16+
17+
18+
library;
19+
//
20+
// Problems in library:
21+
//
22+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:11: Error: Expected a class or mixin body, but got 'xx'.
23+
// class xxx xx XXX extends XXX {
24+
// ^^
25+
//
26+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:14: Error: Expected ';' after this.
27+
// class xxx xx XXX extends XXX {
28+
// ^^^
29+
//
30+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:18: Error: Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
31+
// Try adding the name of the type of the variable or the keyword 'var'.
32+
// class xxx xx XXX extends XXX {
33+
// ^^^^^^^
34+
//
35+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:18: Error: Expected an identifier, but got 'extends'.
36+
// class xxx xx XXX extends XXX {
37+
// ^^^^^^^
38+
//
39+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:18: Error: Expected ';' after this.
40+
// class xxx xx XXX extends XXX {
41+
// ^^^^^^^
42+
//
43+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:26: Error: A function declaration needs an explicit list of parameters.
44+
// Try adding a parameter list to the function declaration.
45+
// class xxx xx XXX extends XXX {
46+
// ^^^
47+
//
48+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:26: Error: 'XXX' is already declared in this scope.
49+
// class xxx xx XXX extends XXX {
50+
// ^^^
51+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:14: Context: Previous declaration of 'XXX'.
52+
// class xxx xx XXX extends XXX {
53+
// ^^^
54+
//
55+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:11: Warning: Type 'xx' not found.
56+
// class xxx xx XXX extends XXX {
57+
// ^^
58+
//
59+
import self as iss;
60+
import "dart:core" as core;
61+
62+
class xxx extends core::Object {
63+
synthetic constructor •() → iss::xxx
64+
;
65+
}
66+
static field invalid-type XXX;
67+
static field dynamic extends;
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
library;
2+
import self as self;
3+
4+
import "org-dartlang-testcase:///issue_36647_lib1.dart";
5+
6+
7+
library;
8+
import self as self2;
9+
import "issue_36647_lib2.dart" as iss;
10+
additionalExports = (iss::xxx)
11+
, iss::XXX)
12+
, iss::extends)
13+
14+
15+
export "org-dartlang-testcase:///issue_36647_lib2.dart";
16+
17+
18+
library;
19+
//
20+
// Problems in library:
21+
//
22+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:11: Error: Expected a class or mixin body, but got 'xx'.
23+
// class xxx xx XXX extends XXX {
24+
// ^^
25+
//
26+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:14: Error: Expected ';' after this.
27+
// class xxx xx XXX extends XXX {
28+
// ^^^
29+
//
30+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:18: Error: Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
31+
// Try adding the name of the type of the variable or the keyword 'var'.
32+
// class xxx xx XXX extends XXX {
33+
// ^^^^^^^
34+
//
35+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:18: Error: Expected an identifier, but got 'extends'.
36+
// class xxx xx XXX extends XXX {
37+
// ^^^^^^^
38+
//
39+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:18: Error: Expected ';' after this.
40+
// class xxx xx XXX extends XXX {
41+
// ^^^^^^^
42+
//
43+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:26: Error: A function declaration needs an explicit list of parameters.
44+
// Try adding a parameter list to the function declaration.
45+
// class xxx xx XXX extends XXX {
46+
// ^^^
47+
//
48+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:26: Error: 'XXX' is already declared in this scope.
49+
// class xxx xx XXX extends XXX {
50+
// ^^^
51+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:14: Context: Previous declaration of 'XXX'.
52+
// class xxx xx XXX extends XXX {
53+
// ^^^
54+
//
55+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:11: Error: Type 'xx' not found.
56+
// class xxx xx XXX extends XXX {
57+
// ^^
58+
//
59+
// pkg/front_end/testcases/regress/issue_36647_lib2.dart:5:11: Error: 'xx' isn't a type.
60+
// class xxx xx XXX extends XXX {
61+
// ^^
62+
//
63+
import self as iss;
64+
import "dart:core" as core;
65+
66+
class xxx extends core::Object {
67+
synthetic constructor •() → iss::xxx
68+
: super core::Object::•()
69+
;
70+
}
71+
static field invalid-type XXX;
72+
static field dynamic extends;

0 commit comments

Comments
 (0)