Skip to content

Commit 7c7c7d0

Browse files
authored
Add diagnostic docs as of 08/23/25 (#6812)
1 parent 817e553 commit 7c7c7d0

9 files changed

+418
-1
lines changed

src/content/tools/diagnostics/index.md

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7177,6 +7177,7 @@ _The type argument(s) of '{0}' can't be inferred._
71777177
<div class="leading">
71787178
</div>
71797179
<div class="trailing">
7180+
<a class="outlined-button" href="/tools/diagnostics/inference_failure_on_collection_literal" title="Learn more about this diagnostic and how to resolve it.">Learn more</a>
71807181
<button class="copy-button filled-button hidden" data-copy="inference_failure_on_collection_literal" title="Copy inference_failure_on_collection_literal to your clipboard.">Copy name</button>
71817182
</div>
71827183
</div>
@@ -7194,6 +7195,7 @@ _The type argument(s) of the function '{0}' can't be inferred._
71947195
<div class="leading">
71957196
</div>
71967197
<div class="trailing">
7198+
<a class="outlined-button" href="/tools/diagnostics/inference_failure_on_function_invocation" title="Learn more about this diagnostic and how to resolve it.">Learn more</a>
71977199
<button class="copy-button filled-button hidden" data-copy="inference_failure_on_function_invocation" title="Copy inference_failure_on_function_invocation to your clipboard.">Copy name</button>
71987200
</div>
71997201
</div>
@@ -7204,13 +7206,14 @@ _The type argument(s) of the function '{0}' can't be inferred._
72047206
</div>
72057207
<div class="card-content">
72067208

7207-
_The return type of '{0}' cannot be inferred._
7209+
_The return type of '{0}' can't be inferred._
72087210

72097211
</div>
72107212
<div class="card-actions">
72117213
<div class="leading">
72127214
</div>
72137215
<div class="trailing">
7216+
<a class="outlined-button" href="/tools/diagnostics/inference_failure_on_function_return_type" title="Learn more about this diagnostic and how to resolve it.">Learn more</a>
72147217
<button class="copy-button filled-button hidden" data-copy="inference_failure_on_function_return_type" title="Copy inference_failure_on_function_return_type to your clipboard.">Copy name</button>
72157218
</div>
72167219
</div>
@@ -7262,6 +7265,7 @@ _The type of {0} can't be inferred without either a type or initializer._
72627265
<div class="leading">
72637266
</div>
72647267
<div class="trailing">
7268+
<a class="outlined-button" href="/tools/diagnostics/inference_failure_on_uninitialized_variable" title="Learn more about this diagnostic and how to resolve it.">Learn more</a>
72657269
<button class="copy-button filled-button hidden" data-copy="inference_failure_on_uninitialized_variable" title="Copy inference_failure_on_uninitialized_variable to your clipboard.">Copy name</button>
72667270
</div>
72677271
</div>
@@ -7279,6 +7283,7 @@ _The type of {0} can't be inferred; a type must be explicitly provided._
72797283
<div class="leading">
72807284
</div>
72817285
<div class="trailing">
7286+
<a class="outlined-button" href="/tools/diagnostics/inference_failure_on_untyped_parameter" title="Learn more about this diagnostic and how to resolve it.">Learn more</a>
72827287
<button class="copy-button filled-button hidden" data-copy="inference_failure_on_untyped_parameter" title="Copy inference_failure_on_untyped_parameter to your clipboard.">Copy name</button>
72837288
</div>
72847289
</div>
@@ -13208,6 +13213,7 @@ _The matched value type '{0}' can never match the required type '{1}'._
1320813213
<div class="leading">
1320913214
</div>
1321013215
<div class="trailing">
13216+
<a class="outlined-button" href="/tools/diagnostics/pattern_never_matches_value_type" title="Learn more about this diagnostic and how to resolve it.">Learn more</a>
1321113217
<button class="copy-button filled-button hidden" data-copy="pattern_never_matches_value_type" title="Copy pattern_never_matches_value_type to your clipboard.">Copy name</button>
1321213218
</div>
1321313219
</div>
@@ -13991,6 +13997,7 @@ _'{0}' was removed in Dart '{1}'_
1399113997
<div class="leading">
1399213998
</div>
1399313999
<div class="trailing">
14000+
<a class="outlined-button" href="/tools/diagnostics/removed_lint_use" title="Learn more about this diagnostic and how to resolve it.">Learn more</a>
1399414001
<button class="copy-button filled-button hidden" data-copy="removed_lint_use" title="Copy removed_lint_use to your clipboard.">Copy name</button>
1399514002
</div>
1399614003
</div>
@@ -16185,6 +16192,7 @@ _Unnecessary cast pattern._
1618516192
<div class="leading">
1618616193
</div>
1618716194
<div class="trailing">
16195+
<a class="outlined-button" href="/tools/diagnostics/unnecessary_cast_pattern" title="Learn more about this diagnostic and how to resolve it.">Learn more</a>
1618816196
<button class="copy-button filled-button hidden" data-copy="unnecessary_cast_pattern" title="Copy unnecessary_cast_pattern to your clipboard.">Copy name</button>
1618916197
</div>
1619016198
</div>
@@ -17632,6 +17640,57 @@ _Use 'package:' imports for files in the 'lib' directory._
1763217640
</div>
1763317641
</div>
1763417642
</div>
17643+
<div class="card outlined-card" id="analyzer_element_model_tracking_bad">
17644+
<div class="card-header">
17645+
<header class="card-title" id="analyzer_element_model_tracking_bad">{{"analyzer_element_model_tracking_bad" | underscoreBreaker}}</header>
17646+
</div>
17647+
<div class="card-content">
17648+
17649+
_Bad tracking annotation for this member._
17650+
17651+
</div>
17652+
<div class="card-actions">
17653+
<div class="leading">
17654+
</div>
17655+
<div class="trailing">
17656+
<button class="copy-button filled-button hidden" data-copy="analyzer_element_model_tracking_bad" title="Copy analyzer_element_model_tracking_bad to your clipboard.">Copy name</button>
17657+
</div>
17658+
</div>
17659+
</div>
17660+
<div class="card outlined-card" id="analyzer_element_model_tracking_more_than_one">
17661+
<div class="card-header">
17662+
<header class="card-title" id="analyzer_element_model_tracking_more_than_one">{{"analyzer_element_model_tracking_more_than_one" | underscoreBreaker}}</header>
17663+
</div>
17664+
<div class="card-content">
17665+
17666+
_There can be only one tracking annotation._
17667+
17668+
</div>
17669+
<div class="card-actions">
17670+
<div class="leading">
17671+
</div>
17672+
<div class="trailing">
17673+
<button class="copy-button filled-button hidden" data-copy="analyzer_element_model_tracking_more_than_one" title="Copy analyzer_element_model_tracking_more_than_one to your clipboard.">Copy name</button>
17674+
</div>
17675+
</div>
17676+
</div>
17677+
<div class="card outlined-card" id="analyzer_element_model_tracking_zero">
17678+
<div class="card-header">
17679+
<header class="card-title" id="analyzer_element_model_tracking_zero">{{"analyzer_element_model_tracking_zero" | underscoreBreaker}}</header>
17680+
</div>
17681+
<div class="card-content">
17682+
17683+
_No required tracking annotation._
17684+
17685+
</div>
17686+
<div class="card-actions">
17687+
<div class="leading">
17688+
</div>
17689+
<div class="trailing">
17690+
<button class="copy-button filled-button hidden" data-copy="analyzer_element_model_tracking_zero" title="Copy analyzer_element_model_tracking_zero to your clipboard.">Copy name</button>
17691+
</div>
17692+
</div>
17693+
</div>
1763517694
<div class="card outlined-card" id="analyzer_public_api_bad_part_directive">
1763617695
<div class="card-header">
1763717696
<header class="card-title" id="analyzer_public_api_bad_part_directive">{{"analyzer_public_api_bad_part_directive" | underscoreBreaker}}</header>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
title: inference_failure_on_collection_literal
3+
description: >-
4+
Details about the inference_failure_on_collection_literal
5+
diagnostic produced by the Dart analyzer.
6+
underscore_breaker_titles: true
7+
body_class: highlight-diagnostics
8+
---
9+
10+
_The type argument(s) of '{0}' can't be inferred._
11+
12+
## Description
13+
14+
The analyzer produces this diagnostic when
15+
- the language option `strict-inference` has been enabled in the analysis options file,
16+
- a list, map or set literal doesn't have type arguments, and
17+
- the values for the type arguments can't be inferred from the elements.
18+
19+
## Example
20+
21+
Given an analysis options file containing the following:
22+
23+
```yaml
24+
analyzer:
25+
language:
26+
strict-inference: true
27+
```
28+
29+
The following code produces this diagnostic because the type of the
30+
elements of the list literal can't be inferred by the analyzer:
31+
32+
```dart
33+
void f() {
34+
var list = [![]!];
35+
print(list);
36+
}
37+
```
38+
39+
## Common fixes
40+
41+
Provide explicit type arguments for the literal:
42+
43+
```dart
44+
void f() {
45+
var list = <int>[];
46+
print(list);
47+
}
48+
```
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
title: inference_failure_on_function_invocation
3+
description: >-
4+
Details about the inference_failure_on_function_invocation
5+
diagnostic produced by the Dart analyzer.
6+
underscore_breaker_titles: true
7+
body_class: highlight-diagnostics
8+
---
9+
10+
_The type argument(s) of the function '{0}' can't be inferred._
11+
12+
## Description
13+
14+
The analyzer produces this diagnostic when
15+
- the language option `strict-inference` has been enabled in the analysis options file,
16+
- the invocation of a method or function doesn't have type arguments, and
17+
- the values for the type arguments can't be inferred.
18+
19+
## Example
20+
21+
Given an analysis options file containing the following:
22+
23+
```yaml
24+
analyzer:
25+
language:
26+
strict-inference: true
27+
```
28+
29+
The following code produces this diagnostic because the invocation of the
30+
method `m` doesn't have type arguments and the type arguments can't be
31+
inferred:
32+
33+
```dart
34+
abstract class C {
35+
void m<T>();
36+
}
37+
38+
void f(C c) {
39+
c.[!m!]();
40+
}
41+
```
42+
43+
## Common fixes
44+
45+
Provide explicit type arguments for the invocation:
46+
47+
```dart
48+
abstract class C {
49+
void m<T>();
50+
}
51+
52+
void f(C c) {
53+
c.m<int>();
54+
}
55+
```
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
title: inference_failure_on_function_return_type
3+
description: >-
4+
Details about the inference_failure_on_function_return_type
5+
diagnostic produced by the Dart analyzer.
6+
underscore_breaker_titles: true
7+
body_class: highlight-diagnostics
8+
---
9+
10+
_The return type of '{0}' can't be inferred._
11+
12+
## Description
13+
14+
The analyzer produces this diagnostic when
15+
- the language option `strict-inference` has been enabled in the analysis options file,
16+
- the declaration of a method or function doesn't have a return type, and
17+
- the return type can't be inferred.
18+
19+
## Example
20+
21+
Given an analysis options file containing the following:
22+
23+
```yaml
24+
analyzer:
25+
language:
26+
strict-inference: true
27+
```
28+
29+
The following code produces this diagnostic because the method `m` doesn't
30+
have a return type:
31+
32+
```dart
33+
class C {
34+
[!m!]() => 7;
35+
}
36+
```
37+
38+
## Common fixes
39+
40+
Add a return type to the method or function:
41+
42+
```dart
43+
class C {
44+
int m() => 7;
45+
}
46+
```
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: inference_failure_on_uninitialized_variable
3+
description: >-
4+
Details about the inference_failure_on_uninitialized_variable
5+
diagnostic produced by the Dart analyzer.
6+
underscore_breaker_titles: true
7+
body_class: highlight-diagnostics
8+
---
9+
10+
_The type of {0} can't be inferred without either a type or initializer._
11+
12+
## Description
13+
14+
The analyzer produces this diagnostic when
15+
- the language option `strict-inference` has been enabled in the analysis options file,
16+
- the declaration of a variable doesn't have a type, and
17+
- the type of the variable can't be inferred.
18+
19+
## Example
20+
21+
Given an analysis options file containing the following:
22+
23+
```yaml
24+
analyzer:
25+
language:
26+
strict-inference: true
27+
```
28+
29+
The following code produces this diagnostic because the variable `s`
30+
doesn't have an explicit type and the type can't be inferred because
31+
there's no initializer:
32+
33+
```dart
34+
var [!s!];
35+
```
36+
37+
## Common fixes
38+
39+
Add an explicit type:
40+
41+
```dart
42+
String? s;
43+
```
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
title: inference_failure_on_untyped_parameter
3+
description: >-
4+
Details about the inference_failure_on_untyped_parameter
5+
diagnostic produced by the Dart analyzer.
6+
underscore_breaker_titles: true
7+
body_class: highlight-diagnostics
8+
---
9+
10+
_The type of {0} can't be inferred; a type must be explicitly provided._
11+
12+
## Description
13+
14+
The analyzer produces this diagnostic when
15+
- the language option `strict-inference` has been enabled in the analysis options file,
16+
- the declaration of a formal parameter doesn't have a type, and
17+
- the type of the parameter can't be inferred.
18+
19+
The type of a parameter of a method can be inferred if the method
20+
overrides an inherited method.
21+
22+
## Example
23+
24+
Given an analysis options file containing the following:
25+
26+
```yaml
27+
analyzer:
28+
language:
29+
strict-inference: true
30+
```
31+
32+
The following code produces this diagnostic because the formal parameter
33+
`p` doesn't have an explicit type and the type can't be inferred:
34+
35+
```dart
36+
void f([!p!]) => print(p);
37+
```
38+
39+
## Common fixes
40+
41+
Add an explicit type:
42+
43+
```dart
44+
void f(int p) => print(p);
45+
```

0 commit comments

Comments
 (0)