ethanblake4 / dart_eval

Extensible Dart interpreter for Dart with full interop

Home Page:https://pub.dev/packages/dart_eval

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CompileError: Cannot box ShowType at unknown (file package:my_package/main.dart)

Noobware1 opened this issue · comments

Test case

 final compiler2 = Compiler();
      compiler2.defineBridgeEnum(BridgeEnumDef(
          BridgeTypeRef(
              BridgeTypeSpec('package:my_package/show.dart', 'ShowType')),
          values: ['Movie', 'Series']));
      final program = compiler2.compile({
        'my_package': {
          'main.dart': r'''
            import 'show.dart';
            class Media {
              Media(this.type, this.url);
              final ShowType type;
              String? url;
            }
            void main() {
              final requiredType = 'movie';
              final type = (requiredType == 'movie') ? 
                ShowType.Movie : ShowType.Series;
              
              final media = Media(type, 'example.com');
              print(media.url);
            }
          '''
        }
      });
      final runtime = Runtime.ofProgram(program);
      runtime.registerBridgeEnumValues('package:my_package/show.dart',
          'ShowType', {'Movie': $int(0), 'Series': $int(1)});
      runtime.executeLib('package:my_package/main.dart', 'main');
    });

Error

CompileError: Cannot box ShowType at unknown (file package:my_package/main.dart)
package:dart_eval/src/eval/compiler/variable.dart 89:7                         Variable.boxIfNeeded
package:dart_eval/src/eval/compiler/statement/variable_declaration.dart 42:19  compileVariableDeclarationList
package:dart_eval/src/eval/compiler/statement/variable_declaration.dart 15:3   compileVariableDeclarationStatement
package:dart_eval/src/eval/compiler/statement/statement.dart 23:12             compileStatement
package:dart_eval/src/eval/compiler/statement/block.dart 17:20                 compileBlock
package:dart_eval/src/eval/compiler/declaration/function.dart 84:14            compileFunctionDeclaration
package:dart_eval/src/eval/compiler/declaration/declaration.dart 24:5          compileDeclaration
package:dart_eval/src/eval/compiler/compiler.dart 492:11                       Compiler.compileSources.<fn>.<fn>
dart:collection                                                                _LinkedHashMapMixin.forEach
package:dart_eval/src/eval/compiler/compiler.dart 481:15                       Compiler.compileSources.<fn>
dart:collection                                                                _LinkedHashMapMixin.forEach
package:dart_eval/src/eval/compiler/compiler.dart 477:32                       Compiler.compileSources
package:dart_eval/src/eval/compiler/compiler.dart 164:12                       Compiler.compile
test\functional1_test.dart 256:33                                              main.<fn>.<fn>

Fixed in c876ca4