dart_eval runtime exception: type 'Null' is not a subtype of type '$Instance' in type cast
HXiaoMing opened this issue · 1 comments
Test case:
import 'package:dart_eval/dart_eval.dart';
import 'package:test/test.dart';
void main() {
group('set value tests', () {
late Compiler compiler;
setUp(() {
compiler = Compiler();
});
test('Using set value', () {
final program = compiler.compile({
'example': {
'main.dart': '''
class TestClass {
int tempValue = 0;
}
bool main() {
final testClass = TestClass();
testClass.tempValue = testClass.hashCode;
print('hashCode \${testClass.tempValue}');
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/set_value_test.dart 31:22 main..
dart_eval runtime exception: type 'Null' is not a subtype of type '$Instance' in type cast
#0 PushObjectProperty.run (package:dart_eval/src/eval/runtime/ops/objects.dart:276:31)
#1 Runtime.execute (package:dart_eval/src/eval/runtime/runtime.dart:823:12)
#2 Runtime.executeLib (package:dart_eval/src/eval/runtime/runtime.dart:810:12)
at main()
RUNTIME STATE
Program offset: 16
Stack sample: [L0: Instance of '$InstanceImpl', *L1: null, L2: null, L3: null, L4: null, L5: null, L6: null, L7: null, L8: null, L9: null]
Args sample: []
Call stack: [0, -1]
TRACE:
10: PushScope (F7:44, 'TestClass.tempValue (set)')
11: SetObjectPropertyImpl (L0[0] = L1)
12: Return (L1)
13: PushScope (F7:101, 'main()')
14: Call (@0)
15: PushReturnValue ()
16: PushObjectProperty (L0.C0) <<< EXCEPTION
17: PushReturnValue ()
18: SetObjectProperty (L0.tempValue = L1)
19: PushConstant (C1)
Fixed in v0.7.9