ethanblake4 / dart_eval

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

dart_eval runtime exception: Expected a value of type 'Completer<dynamic>' when use a Future method with params #117

Open FabrizioBilleciUNICT opened 11 months ago

FabrizioBilleciUNICT commented 11 months ago

Hi I'm working with dart_eval and the current goal is to await an async function which has parameters. Without parameters everything is fine: `void start() async { await aa(); }

Future aa() async { await Future.delayed(const Duration(milliseconds: 1000)); } `

Using parameters: `void start() async { await aa(10, ''); }

Future aa(int value, String tag) async { await Future.delayed(const Duration(milliseconds: 1000)); } ` I receive this error:

dart_eval runtime exception: Expected a value of type 'Completer' , but got one of type '$36int'

ethanblake4 commented 11 months ago

Hi, I can't reproduce this issue in dart_eval v0.6.5. I created the following test:

test('Future method with args', () async {
  final runtime = compiler.compileWriteAndLoad({
    'example': {
      'main.dart': '''
      Future start() async {
        await aa(10, '');
        print('done');
      }

      Future aa(int value, String tag) async {
        await Future.delayed(const Duration(milliseconds: 1000));
      }
      '''
    }
  });
  expect(() async {
    final future =
        runtime.executeLib('package:example/main.dart', 'start') as Future;
    await expectLater(future, completion(null));
  }, prints('done\n'));
});

and it completes successfully.