ethanblake4 / dart_eval

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

enum equality throwing runtime error #136

Closed Noobware1 closed 11 months ago

Noobware1 commented 11 months ago

v0.7.0 i was trying to do this media.type == ShowType.Movie ? media.mediaItem = getMovie(extractIdFromUrl(searchResponse.url)) : null; if i remove this line and directly do media.mediaItem = getMovie(extractIdFromUrl(searchResponse.url)) : it throws no error and works fine

here's the error

Unhandled exception:
dart_eval runtime exception: type 'Null' is not a subtype of type 'EvalFunction' in type cast
#0      CheckEq.run (package:dart_eval/src/eval/runtime/ops/objects.dart:150:55)
#1      Runtime.bridgeCall (package:dart_eval/src/eval/runtime/runtime.dart:838:12)
#2      EvalStaticFunctionPtr.call (package:dart_eval/src/eval/runtime/function.dart:86:13)
at Sflix.loadMediaDetails()

RUNTIME STATE
=============
Program offset: 260
Stack sample: [L0: Instance of '$BasePluginApi', L1: Instance of '$SearchResponse', L2: Instance of '$Completer<dynamic>', L3: Instance of '$DocumentObject', L4: null, L5: Instance of '$MediaDetails', L6: null, L7: $".imdb)", L8: Instance of '$ElementObject', L9: $"IMDB: N/A"]
Call stack: [0, -1]
TRACE:
254: SetObjectProperty (L5.recommendations = L30)
255: PushNull ()
256: PushObjectProperty (L5.C29)
257: PushReturnValue ()
258: LoadGlobal (G1)
259: PushReturnValue ()
260: CheckEq (L32 == L33)  <<< EXCEPTION
261: PushReturnValue ()
262: JumpIfFalse (@280 if L34 == false)
263: PushObjectProperty (L1.C30)

#0      Runtime.bridgeCall (package:dart_eval/src/eval/runtime/runtime.dart:848:7)
#1      EvalStaticFunctionPtr.call (package:dart_eval/src/eval/runtime/function.dart:86:13)
#2      $Bridge.$_invoke (package:dart_eval/src/eval/bridge/runtime_bridge.dart:44:10)
#3      $BasePluginApi.loadMediaDetails (package:extenstions_test/bridge_models/plugin/base_plugin_api.dart:163:26)
#4      main (package:extenstions_test/extenstions_test.dart:208:23)
<asynchronous suspension>
ethanblake4 commented 11 months ago

Is ShowType a bridged enum or defined in the eval code?

Noobware1 commented 11 months ago

It's bridged

Noobware1 commented 11 months ago

Fixed by creating a _superclass $instance

ethanblake4 commented 11 months ago

Fixed in v0.7.1 as well