maks / dart_repl

BSD 3-Clause "New" or "Revised" License
27 stars 0 forks source link

kernel-service: Error: Unhandled exception: Bad state: No element #10

Open liudonghua123 opened 2 years ago

liudonghua123 commented 2 years ago

After I installed this package, I just run var a=123; and print(a), then it crashed.

D:\temp\repl>drepl
The Dart VM service is listening on http://127.0.0.1:8181/WfEY8xjHEc8=/
The Dart DevTools debugger and profiler is available at: http://127.0.0.1:8181/WfEY8xjHEc8=/devtools/#/?uri=ws%3A%2F%2F127.0.0.1%3A8181%2FWfEY8xjHEc8%3D%2Fws
2.17.1 (stable) (Tue May 17 17:58:21 2022 +0000) on "windows_x64"
Type `exit()` or Ctrl-d to quit.
> var a=123;
reloaded
> kernel-service: Error: Unhandled exception:
Bad state: No element
#0      Iterable.first (dart:core/iterable.dart:624:7)
#1      MappedIterable.first (dart:_internal/iterable.dart:370:31)
#2      lookupOrBuildNewIncrementalCompiler (file:///C:/b/s/w/ir/cache/builder/sdk/pkg/vm/bin/kernel_service.dart:443:45)
#3      _processLoadRequest (file:///C:/b/s/w/ir/cache/builder/sdk/pkg/vm/bin/kernel_service.dart:864:22)
#4      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)

Unhandled exception:
Bad state: No element
#0      Iterable.first (dart:core/iterable.dart:624:7)
#1      MappedIterable.first (dart:_internal/iterable.dart:370:31)
#2      lookupOrBuildNewIncrementalCompiler (file:///C:/b/s/w/ir/cache/builder/sdk/pkg/vm/bin/kernel_service.dart:443:45)
#3      _processLoadRequest (file:///C:/b/s/w/ir/cache/builder/sdk/pkg/vm/bin/kernel_service.dart:864:22)
#4      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
^CTerminate batch job (Y/N)? ^C
Y

D:\temp\repl>
maks commented 2 years ago

Thanks for filing this. Not sure what is causing it as I can't replicate it myself locally on Linux. I assume you got this by globally activating the repl package using something like: dart pub global activate --source path D:\temp\repl>drepl ?

In which case I would expect you to have run into #12 which I also need to fix.

I'll try to look into this more soon.

liudonghua123 commented 2 years ago

I installed it via dart pub global activate repl. And it failed with some errors https://github.com/maks/dart_repl/issues/8, then I modified the local code in C:\Users\Liu.D.H\AppData\Local\Pub\Cache\hosted\pub.flutter-io.cn\repl-0.1.0\lib\parser.dart then run dart pub global activate repl again.

liudonghua123 commented 2 years ago

I also found an interesting project on https://github.com/hetu-script/hetu-script#command-line-tool. The hetu works well. But it is not using pure dart syntax.

maks commented 2 years ago

Ah ok, thanks for letting me know, that makes sense now, you edited the local pub cache files. I'd suggest editing local cache files is not the best approach though, I'd rather suggest use your local clone of this repo, edit it and use eg. the --source for testing doing a global activate from it.

In regards to Hetu, yes I've come across it before, its very impressive, but if you are interested in a scripting implementation use Dart syntax then you probably want to look at dart_eval though its not feature complete by any means yet.