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

dart_eval runtime exception: EvalUnknownPropertyException (toString) #174

Closed HXiaoMing closed 9 months ago

HXiaoMing commented 9 months ago

Test case:

import 'package:dart_eval/dart_eval.dart';
import 'package:test/test.dart';

void main() {
  group('hashCode tests', () {
    late Compiler compiler;

    setUp(() {
      compiler = Compiler();
    });

    test('Using hashCode', () {
      final program = compiler.compile({
        'example': {
          'main.dart': '''
            bool main() {
              final value = 5;
              final valueHashCode = value.hashCode;
              print('hashCode \$valueHashCode');
              return true;
            }
          '''
        }
      });

      final runtime = Runtime.ofProgram(program);
      expect(runtime.executeLib('package:example/main.dart', 'main'), true);
    });
  });
}

Error: package:dart_eval/src/eval/runtime/runtime.dart 832:7 Runtime.execute package:dart_eval/src/eval/runtime/runtime.dart 810:12 Runtime.executeLib test/wrapper_test.dart 46:30 main..

dart_eval runtime exception: EvalUnknownPropertyException (toString)

0 EvalFunction.$getProperty (package:dart_eval/src/eval/runtime/function.dart:29:9)

1 InvokeDynamic.run (package:dart_eval/src/eval/runtime/ops/objects.dart:99:45)

2 Runtime.execute (package:dart_eval/src/eval/runtime/runtime.dart:823:12)

at main()

RUNTIME STATE

Program offset: 35 Stack sample: [L0: $1, L1: ${true}, L2: $"count ", L3: $"1", L4: $"count 1", L5: $", isInt ", L6: $"count 1, isInt ", L7: $"true", L8: $"count 1, isInt true", L9: $""] Args sample: [] Call stack: [0, -1] TRACE: 29: PushReturnValue () 30: InvokeExternal (Ex#107) 31: PushReturnValue () 32: PushConstant (C5) 33: PushObjectProperty (L12.C6) 34: PushReturnValue () 35: InvokeDynamic (L14.C1) <<< EXCEPTION 36: PushReturnValue () 37: BoxString (L13) 38: PushArg (L15)

ethanblake4 commented 9 months ago

Fixed in v0.7.5