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

Null check operator used on a null value #46035

Closed
LiamConan opened this issue May 13, 2021 · 5 comments
Closed

Null check operator used on a null value #46035

LiamConan opened this issue May 13, 2021 · 5 comments
Assignees
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. needs-info We need additional information from the issue author (auto-closed after 14 days if no response) P3 A lower priority bug or feature request

Comments

@LiamConan
Copy link

Flutter 2.0.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 1d9032c7e1 (13 days ago) • 2021-04-29 17:37:58 -0700
Engine • revision 05e680e202
Tools • Dart 2.12.3

There is my pubspec :

dependencies:
  flutter:
    sdk: flutter
  cached_network_image: ^3.0.0
  camera: ^0.5.8+17
  cupertino_icons: ^1.0.3
  dio: ^4.0.0
  dotted_border: ^2.0.0
  edit_distance: ^0.4.1
  flappy_search_bar: ^1.7.2
  flutter_keyboard_visibility: ^5.0.1
  flutter_rounded_date_picker: ^2.0.2
  flutter_secure_storage: ^4.2.0
  flutter_speed_dial: ^3.0.5
  flutter_staggered_grid_view: ^0.3.0
  flutter_svg: ^0.22.0
  get_it: ^7.1.3
  image_picker: ^0.7.4
  injectable: ^1.4.0
  intl: ^0.17.0
  json_annotation: ^4.0.1
  json_serializable: ^4.1.1
  liquid_progress_indicator: ^0.3.2
  lottie: ^1.0.1
  modal_bottom_sheet: ^2.0.0
  path_provider: ^2.0.1
  qr_mobile_vision: ^3.0.0
  retrofit: ^2.0.0-beta1
  rxdart: ^0.27.0
  simple_animations: ^3.1.1
  smooth_page_indicator: 0.3.0-nullsafety.0
  supercharged: ^2.0.0
  table_calendar: ^3.0.0
  tuple: ^2.0.0
  url_launcher: ^6.0.3
  week_of_year: ^2.0.0

dev_dependencies:
  flutter_test:
    sdk: flutter
  build_runner: ^1.12.2
  injectable_generator: any
  retrofit_generator: any
  test: ^1.15.7

When I run the build runner it crashes this way on a random file :

$ flutter pub run build_runner build --delete-conflicting-outputs
[INFO] Generating build script...
[INFO] Generating build script completed, took 358ms

[WARNING] Deleted previous snapshot due to missing asset graph.
[INFO] Creating build script snapshot......
[INFO] Creating build script snapshot... completed, took 9.5s

[INFO] There was output on stdout while compiling the build script snapshot, run with --verbose to see it (you will need to run a clean first to re-snapshot).

[INFO] Initializing inputs
[INFO] Building new asset graph...
[INFO] Building new asset graph completed, took 639ms

[INFO] Checking for unexpected pre-existing outputs....
[INFO] Checking for unexpected pre-existing outputs. completed, took 1ms

[INFO] Running build...
[INFO] 1.0s elapsed, 0/16 actions completed.
[INFO] 2.1s elapsed, 0/16 actions completed.
[INFO] 3.1s elapsed, 1/17 actions completed.
[INFO] 4.2s elapsed, 3/19 actions completed.
[INFO] 10.6s elapsed, 15/31 actions completed.
[INFO] 12.9s elapsed, 20/36 actions completed.
[SEVERE] injectable_generator:injectable_builder on lib/application.dart:

Null check operator used on a null value
#0 LinkedElementFactory.isLibraryUri (package:analyzer/src/summary2/linked_element_factory.dart:418:48)
dart-lang/build#1 LibraryContext.isLibraryUri (package:analyzer/src/dart/analysis/library_context.dart:95:27)
dart-lang/build#2 LibraryAnalyzer._isLibrarySource (package:analyzer/src/dart/analysis/library_analyzer.dart:511:25)
dart-lang/build#3 LibraryAnalyzer._resolveDirectives (package:analyzer/src/dart/analysis/library_analyzer.dart:552:36)
dart-lang/build#4 LibraryAnalyzer.analyzeSync (package:analyzer/src/dart/analysis/library_analyzer.dart:128:5)
dart-lang/build#5 LibraryAnalyzer.analyze (package:analyzer/src/dart/analysis/library_analyzer.dart:105:12)
dart-lang/build#6 AnalysisDriver._computeAnalysisResult. (package:analyzer/src/dart/analysis/driver.dart:1590:63)
dart-lang/build#7 PerformanceLog.run (package:analyzer/src/dart/analysis/performance_logger.dart:32:15)
dart-lang/build#8 AnalysisDriver._computeAnalysisResult (package:analyzer/src/dart/analysis/driver.dart:1565:20)
dart-lang/build#9 AnalysisDriver._computeErrors (package:analyzer/src/dart/analysis/driver.dart:1644:26)
dart-lang/build#10 AnalysisDriver.performWork (package:analyzer/src/dart/analysis/driver.dart:1266:20)
dart-lang/build#11 AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2296:24)

The issue is in this function :

bool isLibraryUri(String uriStr) {
  var libraryContext = libraryReaders[uriStr]!; // Here is the issue
  return !libraryContext.hasPartOfDirective;
}

Is there because of the null-safety feature ?
Here it tells that's because of the injectable_generator but if i remove it it will crashes in the same way because of the retrofit generator or the serializable lib.

@simolus3
Copy link
Contributor

I think this is an analyzer bug that has been fixed already (I don't know if that fix has been published yet): #45823 (comment)

@jakemac53
Copy link
Contributor

cc @scheglov

@LiamConan
Copy link
Author

Thanks @simolus3 ! I'll thus wait for the next release.
The only workaround i found is to change the function i quoted into the following one :

bool isLibraryUri(String uriStr) {
  LibraryReader? libraryContext = libraryReaders[uriStr];
  return libraryContext?.hasPartOfDirective==false;
}

I don't know if it's a good idea or if it can break something else (it shouldn't) but it works anyway.

@scheglov
Copy link
Contributor

If this is something that I could reproduce, it might be potentially interesting to try, this error is not something specific related to the code that I replaced, but might be an issue with caching and invalidation. So, while it might have been fixed, there is a chance that it will re-appear differently.

@jakemac53 jakemac53 transferred this issue from dart-lang/build May 17, 2021
@jakemac53 jakemac53 added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label May 17, 2021
@srawlins srawlins added needs-info We need additional information from the issue author (auto-closed after 14 days if no response) P3 A lower priority bug or feature request labels Jul 20, 2021
@no-response
Copy link

no-response bot commented Aug 15, 2021

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. Please don't hesitate to comment on the bug if you have any more information for us; we will reopen it right away!
Thanks for your contribution.

@no-response no-response bot closed this as completed Aug 15, 2021
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. needs-info We need additional information from the issue author (auto-closed after 14 days if no response) P3 A lower priority bug or feature request
Projects
None yet
Development

No branches or pull requests

5 participants