dart_eval icon indicating copy to clipboard operation
dart_eval copied to clipboard

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

Open FabrizioBilleciUNICT opened this issue 1 year ago • 1 comments

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'

FabrizioBilleciUNICT avatar Oct 16 '23 09:10 FabrizioBilleciUNICT

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.

ethanblake4 avatar Oct 16 '23 19:10 ethanblake4