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

Un able to send List<dynamic> argument in functions #214

Closed vijaymsc closed 1 week ago

vijaymsc commented 4 months ago
import 'package:dart_eval/dart_eval.dart';
import 'package:dart_eval/stdlib/core.dart';

const program = '''
  int main(List<dynamic> args) {
  print(args[0]);
    return args[0].length + args[1];
  }
''';

void main(){
  print(eval(program, function: 'main', args: [[$String('vijay'),5]]));
}

Error console

Unhandled exception: type 'int' is not a subtype of type '$Value?' in type cast

0 Runtime.execute (package:dart_eval/src/eval/runtime/runtime.dart:874:7)

1 Runtime.executeLib (package:dart_eval/src/eval/runtime/runtime.dart:854:12)

2 eval (package:dart_eval/src/eval/eval.dart:58:26)

3 main (package:flutter_dynamic_view/test.dart:59:9)

4 _delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:297:19)

5 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

ethanblake4 commented 1 week ago

If you are using dynamic you must use $int.