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 while using a PreferConstConstructorsInImmutables #56940

Closed
yjbanov opened this issue Oct 22, 2024 · 5 comments
Closed

[analyzer] Exception while using a PreferConstConstructorsInImmutables #56940

yjbanov opened this issue Oct 22, 2024 · 5 comments
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@yjbanov
Copy link

yjbanov commented Oct 22, 2024

This tracker is for issues related to:

  • Dart analyzer and linter

In your issue, please include:

  • Dart version and tooling diagnostic info (dart info)
$ dart info

If providing this information as part of reporting a bug, please review the information
below to ensure it only contains things you're comfortable posting publicly.

#### General info

- Dart 3.7.0-50.0.dev (dev) (Mon Oct 21 21:02:55 2024 -0700) on "macos_arm64"
- on macos / Version 14.7 (Build 23H124)
- locale is en

#### Project info

- sdk constraint: '>=3.0.0-0 <4.0.0'
- dependencies: appengine, args, buildbucket, collection, corsac_jwt, crypto, dbcrypt, file, fixnum, gcloud, github, googleapis, googleapis_auth, gql, graphql, grpc, http, json_annotation, logging, meta, mime, mutex, neat_cache, path, process, process_runner, protobuf, retry, truncate, yaml
- dev_dependencies: analyzer, build_runner, fake_async, flutter_lints, json_serializable, mockito, platform, test

#### Process info

|  Memory |  CPU | Elapsed time | Command line                                                                    |
| ------: | ---: | -----------: | ------------------------------------------------------------------------------- |
|   14 MB | 0.0% |  04-21:39:11 | dart devtools --machine --allow-embedding --dtd-uri ws:<path>/3AGmTY8aOG8=      |
|   16 MB | 0.0% |  03-22:46:22 | dart devtools --machine --allow-embedding --dtd-uri ws:<path>/Ml0bmHOvvp4=      |
|   27 MB | 0.0% |  01-00:38:13 | dart devtools --machine --allow-embedding --dtd-uri ws:<path>/NJGA4ZS1ca0=      |
|   52 MB | 0.0% |  03-22:46:23 | dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.98.1 |
|   47 MB | 0.0% |  04-21:39:12 | dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.98.1 |
| 1472 MB | 0.0% |  01-00:38:13 | dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.98.1 |
|   13 MB | 0.0% |  03-22:46:23 | dart tooling-daemon --machine                                                   |
|   13 MB | 0.0% |  04-21:39:12 | dart tooling-daemon --machine                                                   |
|   29 MB | 0.0% |  01-00:38:13 | dart tooling-daemon --machine                                                   |
|   51 MB | 0.0% |  01-00:38:13 | flutter_tools.snapshot daemon                                                   |
  • Whether you are using Windows, macOS, or Linux (if applicable)

Reproduces on Linux (LUCI), and locally on macOS (see dart info above).

Details

dart analyze crashes while analyzing the Cocoon source code at this commit: flutter/cocoon@6dba33b. The output is this:

$ dart analyze
Analyzing app_dart...
An unexpected error was encountered by the Analysis Server.
Please file an issue at https://github.com/dart-lang/sdk/issues/new/choose with the following details:

Internal error: Exception while using a PreferConstConstructorsInImmutables to visit a ConstructorDeclarationImpl in ClassDeclarationImpl in CompilationUnitImpl
type 'ConstructorMember' is not a subtype of type 'ConstructorFragment' in type cast
#0      InterfaceTypeImpl.constructors2.<anonymous closure> (package:analyzer/src/dart/element/type.dart:557:36)
#1      MappedListIterable.elementAt (dart:_internal/iterable.dart:435:31)
#2      ListIterator.moveNext (dart:_internal/iterable.dart:364:26)
#3      new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:189:27)
#4      new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
#5      new List.of (dart:core-patch/array_patch.dart:39:18)
#6      ListIterable.toList (dart:_internal/iterable.dart:224:7)
#7      InterfaceTypeImpl.constructors2 (package:analyzer/src/dart/element/type.dart:558:8)
#8      _Visitor._hasConstConstructorInvocation (package:linter/src/rules/prefer_const_constructors_in_immutables.dart:110:26)
#9      _Visitor.visitConstructorDeclaration (package:linter/src/rules/prefer_const_constructors_in_immutables.dart:58:9)
#10     ConstructorDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:4285:15)
#11     LinterVisitor._runSubscriptions (package:analyzer/src/lint/linter_visitor.dart:1083:14)
#12     LinterVisitor.visitConstructorDeclaration (package:analyzer/src/lint/linter_visitor.dart:206:5)
#13     ConstructorDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:4285:15)
#14     NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:12937:20)
#15     ClassDeclarationImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:2892:13)
#16     LinterVisitor.visitClassDeclaration (package:analyzer/src/lint/linter_visitor.dart:159:10)
#17     ClassDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:2882:50)
#18     NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:12937:20)
#19     CompilationUnitImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:3553:21)
#20     LinterVisitor.visitCompilationUnit (package:analyzer/src/lint/linter_visitor.dart:183:10)
#21     CompilationUnitImpl.accept (package:analyzer/src/dart/ast/ast.dart:3546:50)
#22     LibraryAnalyzer._computeLints (package:analyzer/src/dart/analysis/library_analyzer.dart:410:12)
#23     LibraryAnalyzer._computeDiagnostics (package:analyzer/src/dart/analysis/library_analyzer.dart:334:7)
#24     LibraryAnalyzer.analyze (package:analyzer/src/dart/analysis/library_analyzer.dart:109:5)
#25     AnalysisDriver._analyzeFileImpl.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:1401:11)
<asynchronous suspension>
#26     PerformanceLog.runAsync (package:analyzer/src/dart/analysis/performance_logger.dart:50:14)
<asynchronous suspension>
#27     AnalysisDriver._analyzeFile.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:1315:9)
<asynchronous suspension>
#28     OperationPerformanceImpl.runAsync (package:analyzer/src/util/performance/operation_performance.dart:174:14)
<asynchronous suspension>
#29     AnalysisDriver._analyzeFile (package:analyzer/src/dart/analysis/driver.dart:1312:5)
<asynchronous suspension>
#30     AnalysisDriver._produceErrors (package:analyzer/src/dart/analysis/driver.dart:2017:5)
<asynchronous suspension>
#31     AnalysisDriver.performWork (package:analyzer/src/dart/analysis/driver.dart:1252:7)
<asynchronous suspension>
#32     AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2446:7)
<asynchronous suspension>


null

LUCI log.

@christopherfujino
Copy link
Member

This the pub solve info from the LUCI logs:

+ _discoveryapis_commons 1.0.7
+ _fe_analyzer_shared 67.0.0 (76.0.0 available)
+ analyzer 6.4.1 (6.11.0 available)
+ appengine 0.13.7 (0.13.9 available)
+ archive 3.6.1
+ args 2.5.0 (2.6.0 available)
+ asn1lib 1.5.5 (1.5.6 available)
+ async 2.12.0
+ boolean_selector 2.1.2
+ build 2.4.1
+ build_config 1.1.1
+ build_daemon 4.0.2
+ build_resolvers 2.4.2
+ build_runner 2.4.9 (2.4.13 available)
+ build_runner_core 7.3.2
+ buildbucket 1.0.10 (1.0.12 available)
+ built_collection 5.1.1
+ built_value 8.9.2
+ checked_yaml 2.0.3
+ clock 1.1.1
+ code_builder 4.10.0
+ collection 1.18.0 (1.19.1 available)
+ convert 3.1.2
+ corsac_jwt 1.0.0-nullsafety.1 (1.0.1 available)
+ coverage 1.10.0
+ crypto 3.0.3 (3.0.6 available)
+ dart_style 2.3.6 (2.3.7 available)
+ dbcrypt 2.0.0
+ fake_async 1.3.1 (1.3.2 available)
+ file 7.0.0 (7.0.1 available)
+ fixnum 1.1.0 (1.1.1 available)
+ flutter_lints 3.0.2 (5.0.0 available)
+ frontend_server_client 4.0.0
+ gcloud 0.8.12 (0.8.15 available)
+ github 9.24.0
+ glob 2.1.2
+ google_identity_services_web 0.3.1+4
+ googleapis 12.0.0 (13.2.0 available)
+ googleapis_auth 1.6.0
+ gql 1.0.1-alpha+1709845491443 (1.0.1-alpha+1717789143880 available)
+ gql_dedupe_link 2.0.4-alpha+1709845491527 (2.0.4-alpha+1715521079596 available)
+ gql_error_link 1.0.0+1
+ gql_exec 1.1.1-alpha+1699813812660
+ gql_http_link 1.1.0
+ gql_link 1.0.1-alpha+1709845491457 (1.0.1-alpha+1717789143896 available)
+ gql_transform_link 1.0.0
+ graphql 5.2.0-beta.7 (5.2.0-beta.9 available)
+ graphs 2.3.2
+ grpc 3.2.4 (4.0.1 available)
+ hive 2.2.3
+ http 1.2.1 (1.2.2 available)
+ http2 2.3.0
+ http_multi_server 3.2.1
+ http_parser 4.0.2 (4.1.1 available)
+ io 1.0.4
+ js 0.7.1
+ json_annotation 4.8.1 (4.9.0 available)
+ json_serializable 6.7.1 (6.8.0 available)
+ lints 3.0.0 (5.1.0 available)
+ logging 1.2.0 (1.3.0 available)
+ matcher 0.12.16+1 (0.12.17 available)
+ meta 1.14.0 (1.16.0 available)
+ mime 1.0.5 (2.0.0 available)
+ mockito 5.4.4
+ mutex 3.1.0
+ neat_cache 2.0.4
+ node_preamble 2.0.2
+ normalize 0.8.2+1 (0.9.1 available)
+ package_config 2.1.0
+ path 1.9.0 (1.9.1 available)
+ platform 3.1.4 (3.1.6 available)
+ pointycastle 3.9.1
+ pool 1.5.1
+ process 5.0.2
+ process_runner 4.2.0
! protobuf 3.1.0 (overridden)
+ protoc_plugin 21.1.2
+ pub_semver 2.1.4
+ pubspec_parse 1.3.0
+ retry 3.1.2
+ rsa_pkcs 2.1.0
+ rxdart 0.27.7 (0.28.0 available)
+ shelf 1.4.1 (1.4.2 available)
+ shelf_packages_handler 3.0.2
+ shelf_static 1.1.3
+ shelf_web_socket 1.0.4 (2.0.0 available)
+ source_gen 1.5.0
+ source_helper 1.3.4
+ source_map_stack_trace 2.1.2
+ source_maps 0.10.12
+ source_span 1.10.0
+ sprintf 7.0.0
+ stack_trace 1.12.0
+ stream_channel 2.1.2
+ stream_transform 2.1.0
+ string_scanner 1.4.0
+ term_glyph 1.2.1
+ test 1.25.3 (1.25.8 available)
+ test_api 0.7.1 (0.7.3 available)
+ test_core 0.6.1 (0.6.5 available)
+ timing 1.0.1
+ truncate 3.0.1
+ typed_data 1.4.0
+ uuid 4.5.1
+ vm_service 14.3.1
+ watcher 1.1.0
+ web 0.5.1 (1.1.0 available)
+ web_socket_channel 2.4.5 (3.0.1 available)
+ webkit_inspection_protocol 1.2.1
+ yaml 3.1.2

@dart-github-bot
Copy link
Collaborator

Summary: The Dart analyzer crashes with an internal error while analyzing the Cocoon source code, specifically when using the PreferConstConstructorsInImmutables linter rule. The error message indicates a type mismatch during the analysis process.

@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 Oct 22, 2024
@yjbanov
Copy link
Author

yjbanov commented Oct 22, 2024

Notably, I just reran dart analyze in the same directory a second time, and it did not crash.

@bwilkerson
Copy link
Member

@scheglov @pq

@lrhn lrhn removed the triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. label Oct 22, 2024
@scheglov
Copy link
Contributor

Fixes in f65f719.

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. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

6 participants