Skip to content

Commit 7eb48a9

Browse files
srawlinsCommit Queue
authored andcommitted
lint rule: avoid_void_async: report on local main functions
Fixes https://github.com/dart-lang/linter/issues/4941 Change-Id: Icd417fdb591e832cbf4698156f622ea13f8fcaad Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389800 Reviewed-by: Phil Quitslund <[email protected]> Commit-Queue: Phil Quitslund <[email protected]> Auto-Submit: Samuel Rawlins <[email protected]>
1 parent 5d5977f commit 7eb48a9

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

pkg/linter/lib/src/rules/avoid_void_async.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class _Visitor extends SimpleAstVisitor<void> {
3838

3939
@override
4040
void visitFunctionDeclaration(FunctionDeclaration node) {
41-
if (node.name.lexeme == 'main') return;
41+
if (node.name.lexeme == 'main' && node.parent is CompilationUnit) return;
4242
_check(
4343
declaredElement: node.declaredElement,
4444
returnType: node.returnType,

pkg/linter/test/rules/avoid_void_async_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ void f() {
112112
]);
113113
}
114114

115-
@FailingTest(issue: 'https://github.com/dart-lang/linter/issues/4941')
116115
test_functionLocal_main_async_arrow() async {
117116
await assertDiagnostics(r'''
118117
void f() {

0 commit comments

Comments
 (0)