ethanblake4 / dart_eval

Extensible Dart interpreter for Dart with full interop
https://pub.dev/packages/dart_eval
BSD 3-Clause "New" or "Revised" License
334 stars 40 forks source link

Null check operator used on a null value on OffsetTracker.apply #137

Closed Noobware1 closed 1 year ago

Noobware1 commented 1 year ago

steps to reproduce the error (ignore the commented code)

Runtime runtimeEval(Uint8List bytecode) {
  final runtime = Runtime(bytecode.buffer.asByteData());

  // runtime.grant(NetworkPermission.any);

  //Enums
  // $ShowType.configureForRuntime(runtime);
  // $ShowStaus.configureForRuntime(runtime);
  // $MediaItemType.configureForRuntime(runtime);
  // $MediaType.configureForRuntime(runtime);
  // $SubtitleFormat.configureForRuntime(runtime);
  // $VideoFormat.configureForRuntime(runtime);

  //Extenstions
  // $StringUtils.configureForRuntime(runtime);
  // $IterableUtils.configureForRuntime(runtime);
  // $ListUtils.configureForRuntime(runtime);
  // $CryptoUtils.configureForRuntime(runtime);

  //OkHttp
  // $ElementObject.configureForRuntime(runtime);
  // $DocumentObject.configureForRuntime(runtime);
  // $OkHttpResponseObject.configureForRuntime(runtime);

  //MediaDetails
  // $MediaDetails.configureForRuntime(runtime);
  // $SearchResponse.configureForRuntime(runtime);
  // $ActorData.configureForRuntime(runtime);
  // $SeasonData.configureForRuntime(runtime);
  // $Episode.configureForRuntime(runtime);
  // $SeasonList.configureForRuntime(runtime);
  // $MediaItem.configureForRuntime(runtime);
  // $Anime.configureForRuntime(runtime);
  // $TvSeries.configureForRuntime(runtime);
  // $Movie.configureForRuntime(runtime);
  // $ExtractorLink.configureForRuntime(runtime);

  //Meiyou utils
  // $MeiyouUtils.configureForRuntime(runtime);

  //Media
  // $Media.configureForRuntime(runtime);
  // $Subtitle.configureForRuntime(runtime);
  // $Video.configureForRuntime(runtime);
  // $VideoQuality.configureForRuntime(runtime);
  // $VideoSource.configureForRuntime(runtime);
  // $Subtitle.configureForRuntime(runtime);

  //App utils
  // $MeiyouUtils.configureForRuntime(runtime);

  //Interfaces
  // $ExtractorApi.configureForRuntime(runtime);
  // $BasePluginApi.configureForRuntime(runtime);

  runtime.setup();

  return runtime;
}

void main() {
  final compiler = Compiler();
  final compiled = compiler.compile({
    'extenstions_test': {
      'main.dart':
          '''main() {
  var episode = RegExp(r'\\d+').firstMatch('episode 1');
  print(episode);
}'''
    }
  }).write();

  final runtime = runtimeEval(compiled);

  final value = (await runtime.executeLib(
    'package:extenstions_test/main.dart',
    'main',
  ));
  print(value);
}

error

Unhandled exception:
Null check operator used on a null value
#0      OffsetTracker.apply.<anonymous closure> (package:dart_eval/src/eval/compiler/offset_tracker.dart:22:33)
#1      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:625:13)
#2      OffsetTracker.apply (package:dart_eval/src/eval/compiler/offset_tracker.dart:16:22)
#3      Compiler.compileSources (package:dart_eval/src/eval/compiler/compiler.dart:534:28)
#4      Compiler.compile (package:dart_eval/src/eval/compiler/compiler.dart:164:12)
#5      main (package:extenstions_test/extenstions_test.dart:175:29)
#6      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:294:33)
#7      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189:12)

and also this error doesn't occur when i use compiler write and load function. thank you.

ethanblake4 commented 1 year ago

Fixed in v0.7.1