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

Null check operator used on a null value #195

Open HXiaoMing opened 8 months ago

HXiaoMing commented 8 months ago

test case:

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

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

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

    test('simple test', () {
      final program = compiler.compile({
        'example': {
          'main.dart': '''
            const int bbb = aaa;
            const int aaa = 111;

            int main() {
              return bbb;
            }
          '''
        }
      });

      final runtime = Runtime.ofProgram(program);

      final result = runtime.executeLib('package:example/main.dart', 'main');
      print('result $result');
    });
  });
}

Error: package:dart_eval/src/eval/compiler/reference.dart 601:78 _declarationToVariable package:dart_eval/src/eval/compiler/reference.dart 354:12 IdentifierReference.getValue package:dart_eval/src/eval/compiler/expression/identifier.dart 13:48 compileIdentifier package:dart_eval/src/eval/compiler/expression/expression.dart 36:12 compileExpression package:dart_eval/src/eval/compiler/declaration/variable.dart 17:13 compileTopLevelVariableDeclaration package:dart_eval/src/eval/compiler/declaration/declaration.dart 32:5 compileDeclaration package:dart_eval/src/eval/compiler/compiler.dart 452:13 Compiler.compileSources.. dart:collection _LinkedHashMapMixin.forEach package:dart_eval/src/eval/compiler/compiler.dart 444:15 Compiler.compileSources. dart:collection _LinkedHashMapMixin.forEach package:dart_eval/src/eval/compiler/compiler.dart 443:32 Compiler.compileSources package:dart_eval/src/eval/compiler/compiler.dart 163:12 Compiler.compile test/static_simple.dart 13:32 main..

Null check operator used on a null value