Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analyzer exception doesn't specify affected file #56281

Open
Lootwig opened this issue Jul 18, 2024 · 3 comments
Open

Analyzer exception doesn't specify affected file #56281

Lootwig opened this issue Jul 18, 2024 · 3 comments
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. dart-cli-fix P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@Lootwig
Copy link
Contributor

Lootwig commented Jul 18, 2024

Encountering this trying to run dart fix --apply:

Console output ``` Internal error: Exception while using a AvoidRedundantArgumentValues to visit a FunctionExpressionInvocationImpl in NamedExpressionImpl in ArgumentListImpl in InstanceCreationExpressionImpl in ListLiteralImpl in NamedExpressionImpl in ArgumentListImpl in InstanceCreationExpressionImpl in NamedExpressionImpl in ArgumentListImpl in InstanceCreationExpressionImpl in ReturnStatementImpl in BlockImpl in BlockFunctionBodyImpl in MethodDeclarationImpl in ClassDeclarationImpl in CompilationUnitImpl Bad state: [library: null][this: (DefaultParameterElementImpl) {double? height}][enclosingElement: null][reference: null] #0 ConstVariableElement.computeConstantValue (package:analyzer/src/dart/element/element.dart:1292:9) #1 _Visitor.checkArgument (package:linter/src/rules/avoid_redundant_argument_values.dart:105:23) #2 _Visitor.check (package:linter/src/rules/avoid_redundant_argument_values.dart:88:7) #3 _Visitor.visitFunctionExpressionInvocation (package:linter/src/rules/avoid_redundant_argument_values.dart:126:5) #4 FunctionExpressionInvocationImpl.accept (package:analyzer/src/dart/ast/ast.dart:8382:15) #5 LinterVisitor._runSubscriptions (package:analyzer/src/lint/linter_visitor.dart:1096:14) #6 LinterVisitor.visitFunctionExpressionInvocation (package:analyzer/src/lint/linter_visitor.dart:446:5) #7 FunctionExpressionInvocationImpl.accept (package:analyzer/src/dart/ast/ast.dart:8382:15) #8 NamedExpressionImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:12187:17) #9 LinterVisitor.visitNamedExpression (package:analyzer/src/lint/linter_visitor.dart:663:10) #10 NamedExpressionImpl.accept (package:analyzer/src/dart/ast/ast.dart:12177:50) #11 NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:12587:20) #12 ArgumentListImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:498:16) #13 LinterVisitor.visitArgumentList (package:analyzer/src/lint/linter_visitor.dart:45:10) #14 ArgumentListImpl.accept (package:analyzer/src/dart/ast/ast.dart:494:50) #15 InstanceCreationExpressionImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:10138:19) #16 LinterVisitor.visitInstanceCreationExpression (package:analyzer/src/lint/linter_visitor.dart:537:10) #17 InstanceCreationExpressionImpl.accept (package:analyzer/src/dart/ast/ast.dart:10127:15) #18 NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:12587:20) #19 ListLiteralImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:10978:15) #20 LinterVisitor.visitListLiteral (package:analyzer/src/lint/linter_visitor.dart:597:10) #21 ListLiteralImpl.accept (package:analyzer/src/dart/ast/ast.dart:10968:50) #22 NamedExpressionImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:12187:17) #23 LinterVisitor.visitNamedExpression (package:analyzer/src/lint/linter_visitor.dart:663:10) #24 NamedExpressionImpl.accept (package:analyzer/src/dart/ast/ast.dart:12177:50) #25 NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:12587:20) #26 ArgumentListImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:498:16) #27 LinterVisitor.visitArgumentList (package:analyzer/src/lint/linter_visitor.dart:45:10) #28 ArgumentListImpl.accept (package:analyzer/src/dart/ast/ast.dart:494:50) #29 InstanceCreationExpressionImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:10138:19) #30 LinterVisitor.visitInstanceCreationExpression (package:analyzer/src/lint/linter_visitor.dart:537:10) #31 InstanceCreationExpressionImpl.accept (package:analyzer/src/dart/ast/ast.dart:10127:15) #32 NamedExpressionImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:12187:17) #33 LinterVisitor.visitNamedExpression (package:analyzer/src/lint/linter_visitor.dart:663:10) #34 NamedExpressionImpl.accept (package:analyzer/src/dart/ast/ast.dart:12177:50) #35 NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:12587:20) #36 ArgumentListImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:498:16) #37 LinterVisitor.visitArgumentList (package:analyzer/src/lint/linter_visitor.dart:45:10) #38 ArgumentListImpl.accept (package:analyzer/src/dart/ast/ast.dart:494:50) #39 InstanceCreationExpressionImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:10138:19) #40 LinterVisitor.visitInstanceCreationExpression (package:analyzer/src/lint/linter_visitor.dart:537:10) #41 InstanceCreationExpressionImpl.accept (package:analyzer/src/dart/ast/ast.dart:10127:15) #42 ReturnStatementImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:15092:18) #43 LinterVisitor.visitReturnStatement (package:analyzer/src/lint/linter_visitor.dart:873:10) #44 ReturnStatementImpl.accept (package:analyzer/src/dart/ast/ast.dart:15088:50) #45 NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:12587:20) #46 BlockImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:2091:17) #47 LinterVisitor.visitBlock (package:analyzer/src/lint/linter_visitor.dart:111:10) #48 BlockImpl.accept (package:analyzer/src/dart/ast/ast.dart:2087:50) #49 BlockFunctionBodyImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:2047:12) #50 LinterVisitor.visitBlockFunctionBody (package:analyzer/src/lint/linter_visitor.dart:117:10) #51 BlockFunctionBodyImpl.accept (package:analyzer/src/dart/ast/ast.dart:2039:50) #52 MethodDeclarationImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:11697:10) #53 LinterVisitor.visitMethodDeclaration (package:analyzer/src/lint/linter_visitor.dart:639:10) #54 MethodDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:11689:50) #55 NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:12587:20) #56 ClassDeclarationImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:2954:13) #57 LinterVisitor.visitClassDeclaration (package:analyzer/src/lint/linter_visitor.dart:165:10) #58 ClassDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:2944:50) #59 NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:12587:20) #60 CompilationUnitImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:3618:21) #61 LinterVisitor.visitCompilationUnit (package:analyzer/src/lint/linter_visitor.dart:189:10) #62 CompilationUnitImpl.accept (package:analyzer/src/dart/ast/ast.dart:3611:50) #63 LibraryAnalyzer._computeLints (package:analyzer/src/dart/analysis/library_analyzer.dart:406:12) #64 LibraryAnalyzer._computeDiagnostics (package:analyzer/src/dart/analysis/library_analyzer.dart:331:7) #65 LibraryAnalyzer.analyze (package:analyzer/src/dart/analysis/library_analyzer.dart:109:5) #66 AnalysisDriver._analyzeFileImpl. (package:analyzer/src/dart/analysis/driver.dart:1394:11) #67 PerformanceLog.runAsync (package:analyzer/src/dart/analysis/performance_logger.dart:50:14) #68 AnalysisDriver._analyzeFile. (package:analyzer/src/dart/analysis/driver.dart:1308:9) #69 OperationPerformanceImpl.runAsync (package:analyzer/src/util/performance/operation_performance.dart:174:14) #70 AnalysisDriver._analyzeFile (package:analyzer/src/dart/analysis/driver.dart:1305:5) #71 AnalysisDriver._getErrors (package:analyzer/src/dart/analysis/driver.dart:1739:5) #72 AnalysisDriver.performWork (package:analyzer/src/dart/analysis/driver.dart:1207:7) #73 AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2449:7) ```

When trying to pin down the problematic file(s) by running folder-by-folder, the error stopped occurring after processing a folder's subdirs (upon whose analysis the exception occurred) individually. None raised the error when analyzed by itself, after which the parent ran just fine as well.

Request: It would be super helpful to include the currently processed file's path whenever an exception is thrown.

@dart-github-bot
Copy link
Collaborator

Summary: The dart fix --apply command fails with an analyzer exception that doesn't specify the affected file. The exception occurs while analyzing a FunctionExpressionInvocationImpl node and mentions a ConstVariableElement with a null library and enclosing element.

@dart-github-bot dart-github-bot added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Jul 18, 2024
@Lootwig
Copy link
Contributor Author

Lootwig commented Jul 18, 2024

Update: I can reproduce the exception on the very fist run of dart fix --apply after running pub get. If there were no fixes applied and I don't touch any files, the error does not appear again on subsequent runs.

@lrhn lrhn removed the triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. label Jul 19, 2024
@srawlins srawlins added type-enhancement A request for a change that isn't a bug dart-cli-fix and removed type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Jul 24, 2024
@srawlins
Copy link
Member

Great request! Might be tricky to implement, as we cannot collect any personally identifiable info, including file paths, in our crash reporting. A very good feature to have though.

@srawlins srawlins added the P2 A bug or feature request we're likely to work on label Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. dart-cli-fix P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants