Skip to content

Dart compiler exception with Flutter master #32729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mravn-google opened this issue Apr 1, 2018 · 2 comments
Closed

Dart compiler exception with Flutter master #32729

mravn-google opened this issue Apr 1, 2018 · 2 comments
Assignees
Labels
crash Process exits with SIGSEGV, SIGABRT, etc. An unhandled exception is not a crash. legacy-area-front-end Legacy: Use area-dart-model instead. P1 A high priority bug; for example, a single project is unusable or has many test failures
Milestone

Comments

@mravn-google
Copy link

Snippet from flutter doctor -v

[✓] Flutter (Channel master, v0.2.7-pre.5, on Mac OS X 10.13.3 17D102, locale en-US)
    • Flutter version 0.2.7-pre.5 at /Users/mravn/github/flutter
    • Framework revision 68db514ec0 (32 hours ago), 2018-03-30 19:48:51 -0700
    • Engine revision c903c217a1
    • Dart version 2.0.0-dev.43.0.flutter-52afcba357

Error (the Dart compiler is invoked by Gradle calling into Flutter tooling):

$ flutter run
Running "flutter packages get" in example...                 1.1s
Launching lib/main.dart on Nexus 5X in debug mode...
Initializing gradle...                                       0.8s
Resolving dependencies...                                    0.9s
Running 'gradlew assembleDebug'...                               
compiler message: Unhandled exception:
Crash when compiling file:///Users/mravn/apps/music/example/lib/main.dart,
at character offset 764:
lib/main.dart:52:24: Internal problem: Unhandled () → void => #lib1::play(song, 1.0) in defaultTreeNode.
                onTap: () => play(song, 1.0),
                       ^
#0      internalProblem (package:front_end/src/fasta/problems.dart:30)
#1      unhandled (package:front_end/src/fasta/problems.dart:43)
#2      ConstnessEvaluator.defaultTreeNode (package:front_end/src/fasta/kernel/constness_evaluator.dart:112)
#3      TreeVisitor.defaultExpression (package:kernel/visitor.dart:140)
#4      TreeVisitor.visitFunctionExpression (package:kernel/visitor.dart:177)
#5      FunctionExpression.accept (package:kernel/ast.dart:3513)
#6      ConstnessEvaluator.visitConstructorInvocation (package:front_end/src/fasta/kernel/constness_evaluator.dart:175)
#7      ConstructorInvocation.accept (package:kernel/ast.dart:2983)
#8      ConstnessEvaluator.evaluate (package:front_end/src/fasta/kernel/constness_evaluator.dart:99)
#9      evaluateConstness (package:front_end/src/fasta/kernel/constness_evaluator.dart:466)
#10     BodyBuilder.inferConstness (package:front_end/src/fasta/kernel/body_builder.dart:710)
#11     BodyBuilder.finishFunction (package:front_end/src/fasta/kernel/body_builder.dart:697)
#12     DietListener.listenerFinishFunction (package:front_end/src/fasta/source/diet_listener.dart:684)
#13     DietListener.parseFunctionBody (package:front_end/src/fasta/source/diet_listener.dart:718)
#14     DietListener.buildFunctionBody (package:front_end/src/fasta/source/diet_listener.dart:565)
#15     DietListener.endMethod (package:front_end/src/fasta/source/diet_listener.dart:530)
#16     Parser.parseMethod (package:front_end/src/fasta/parser/parser.dart:3796)
#17     Parser.parseClassMemberImpl (package:front_end/src/fasta/parser/parser.dart:3670)
#18     Parser.parseClassBody (package:front_end/src/fasta/parser/parser.dart:3467)
#19     Parser.parseClass (package:front_end/src/fasta/parser/parser.dart:1699)
#20     Parser.parseClassOrNamedMixinApplication (package:front_end/src/fasta/parser/parser.dart:1659)
#21     Parser.parseTopLevelKeywordDeclaration (package:front_end/src/fasta/parser/parser.dart:535)
#22     Parser.parseTopLevelDeclarationImpl (package:front_end/src/fasta/parser/parser.dart:451)
#23     Parser.parseUnit (package:front_end/src/fasta/parser/parser.dart:335)
#24     SourceLoader.buildBody (package:front_end/src/fasta/source/source_loader.dart:198)
<asynchronous suspension>
#25     Loader.buildBodies (package:front_end/src/fasta/loader.dart:157)
<asynchronous suspension>
#26     KernelTarget.buildComponent (package:front_end/src/fasta/kernel/kernel_target.dart:292)
<asynchronous suspension>
#27     IncrementalCompiler.computeDelta.<anonymous closure> (package:front_end/src/fasta/incremental_compiler.dart:140)
<asynchronous suspension>
#28     CompilerContext.runInContext.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:105)
#29     _rootRun (dart:async/zone.dart:1126)
#30     _CustomZone.run (dart:async/zone.dart:1023)
#31     runZoned (dart:async/zone.dart:1501)
#32     CompilerContext.runInContext (package:front_end/src/fasta/compiler_context.dart:105)
#33     IncrementalCompiler.computeDelta (package:front_end/src/fasta/incremental_compiler.dart:61)
<asynchronous suspension>
#34     IncrementalCompiler.compile (package:vm/incremental_compiler.dart:33)
<asynchronous suspension>
#35     FrontendCompiler.compile.<anonymous closure> (package:vm/frontend_server.dart:254)
#36     new Future.<anonymous closure> (dart:async/future.dart:174)
#37     _rootRun (dart:async/zone.dart:1122)
#38     _CustomZone.run (dart:async/zone.dart:1023)
#39     _CustomZone.runGuarded (dart:async/zone.dart:925)
#40     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:965)
#41     _rootRun (dart:async/zone.dart:1126)
#42     _CustomZone.run (dart:async/zone.dart:1023)
#43     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:949)
#44     Timer._createTimer.<anonymous closure> (dart:async-patch/dart:async/timer_patch.dart:21)
#45     _Timer._runTimers (dart:isolate-patch/dart:isolate/timer_impl.dart:382)
#46     _Timer._handleMessage (dart:isolate-patch/dart:isolate/timer_impl.dart:416)
#47     _RawReceivePortImpl._handleMessage (dart:isolate-patch/dart:isolate/isolate_patch.dart:165)


#0      internalProblem (package:front_end/src/fasta/problems.dart:30)
#1      unhandled (package:front_end/src/fasta/problems.dart:43)
#2      ConstnessEvaluator.defaultTreeNode (package:front_end/src/fasta/kernel/constness_evaluator.dart:112)
#3      TreeVisitor.defaultExpression (package:kernel/visitor.dart:140)
#4      TreeVisitor.visitFunctionExpression (package:kernel/visitor.dart:177)
#5      FunctionExpression.accept (package:kernel/ast.dart:3513)
#6      ConstnessEvaluator.visitConstructorInvocation (package:front_end/src/fasta/kernel/constness_evaluator.dart:175)
#7      ConstructorInvocation.accept (package:kernel/ast.dart:2983)
#8      ConstnessEvaluator.evaluate (package:front_end/src/fasta/kernel/constness_evaluator.dart:99)
#9      evaluateConstness (package:front_end/src/fasta/kernel/constness_evaluator.dart:466)
#10     BodyBuilder.inferConstness (package:front_end/src/fasta/kernel/body_builder.dart:710)
#11     BodyBuilder.finishFunction (package:front_end/src/fasta/kernel/body_builder.dart:697)
#12     DietListener.listenerFinishFunction (package:front_end/src/fasta/source/diet_listener.dart:684)
#13     DietListener.parseFunctionBody (package:front_end/src/fasta/source/diet_listener.dart:718)
#14     DietListener.buildFunctionBody (package:front_end/src/fasta/source/diet_listener.dart:565)
#15     DietListener.endMethod (package:front_end/src/fasta/source/diet_listener.dart:530)
#16     Parser.parseMethod (package:front_end/src/fasta/parser/parser.dart:3796)
#17     Parser.parseClassMemberImpl (package:front_end/src/fasta/parser/parser.dart:3670)
#18     Parser.parseClassBody (package:front_end/src/fasta/parser/parser.dart:3467)
#19     Parser.parseClass (package:front_end/src/fasta/parser/parser.dart:1699)
#20     Parser.parseClassOrNamedMixinApplication (package:front_end/src/fasta/parser/parser.dart:1659)
#21     Parser.parseTopLevelKeywordDeclaration (package:front_end/src/fasta/parser/parser.dart:535)
#22     Parser.parseTopLevelDeclarationImpl (package:front_end/src/fasta/parser/parser.dart:451)
#23     Parser.parseUnit (package:front_end/src/fasta/parser/parser.dart:335)
#24     SourceLoader.buildBody (package:front_end/src/fasta/source/source_loader.dart:198)
<asynchronous suspension>
#25     Loader.buildBodies (package:front_end/src/fasta/loader.dart:157)
<asynchronous suspension>
#26     KernelTarget.buildComponent (package:front_end/src/fasta/kernel/kernel_target.dart:292)
<asynchronous suspension>
#27     IncrementalCompiler.computeDelta.<anonymous closure> (package:front_end/src/fasta/incremental_compiler.dart:140)
<asynchronous suspension>
#28     CompilerContext.runInContext.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:105)
#29     _rootRun (dart:async/zone.dart:1126)
#30     _CustomZone.run (dart:async/zone.dart:1023)
#31     runZoned (dart:async/zone.dart:1501)
#32     CompilerContext.runInContext (package:front_end/src/fasta/compiler_context.dart:105)
#33     IncrementalCompiler.computeDelta (package:front_end/src/fasta/incremental_compiler.dart:61)
<asynchronous suspension>
#34     IncrementalCompiler.compile (package:vm/incremental_compiler.dart:33)
<asynchronous suspension>
#35     FrontendCompiler.compile.<anonymous closure> (package:vm/frontend_server.dart:254)
#36     new Future.<anonymous closure> (dart:async/future.dart:174)
#37     _rootRun (dart:async/zone.dart:1122)
#38     _CustomZone.run (dart:async/zone.dart:1023)
#39     _CustomZone.runGuarded (dart:async/zone.dart:925)
#40     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:965)
#41     _rootRun (dart:async/zone.dart:1126)
#42     _CustomZone.run (dart:async/zone.dart:1023)
#43     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:949)
#44     Timer._createTimer.<anonymous closure> (dart:async-patch/dart:async/timer_patch.dart:21)
#45     _Timer._runTimers (dart:isolate-patch/dart:isolate/timer_impl.dart:382)
#46     _Timer._handleMessage (dart:isolate-patch/dart:isolate/timer_impl.dart:416)
#47     _RawReceivePortImpl._handleMessage (dart:isolate-patch/dart:isolate/isolate_patch.dart:165)

Compiler terminated unexpectedly on /Users/mravn/apps/music/example/lib/main.dart

FAILURE: Build failed with an exception.

* Where:
Script '/Users/mravn/github/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 441

* What went wrong:
Execution failed for task ':app:flutterBuildDebug'.
> Process 'command '/Users/mravn/github/flutter/bin/flutter'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 5s
Gradle build failed: 1
$

main.dart:

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:music/music.dart';

void main() {
  runApp(MaterialApp(
    home: Scaffold(
      appBar: AppBar(title: Text('Musical App')),
      body: Center(child: MusicPlayer()),
    ),
  ));
}

class MusicPlayer extends StatefulWidget {
  @override
  _MusicPlayerState createState() => _MusicPlayerState();
}

class _MusicPlayerState extends State<MusicPlayer> {
  Future<List<Song>> _songsFuture;

  @override
  void initState() {
    super.initState();
    _songsFuture = isLicensed().then<List<Song>>((bool isLicensed) {
      if (isLicensed) {
        return songs();
      } else {
        throw 'Game over\nInsert coins';
      }
    });
  }

  @override
  Widget build(BuildContext context) {
    return FutureBuilder<List<Song>>(
      future: _songsFuture,
      builder: (_, AsyncSnapshot<List<Song>> snapshot) {
        if (snapshot.hasError) {
          return Text(snapshot.error.toString());
        } else if (snapshot.hasData) {
          final List<Song> songs = snapshot.data;
          return ListView.builder(
            itemCount: songs.length,
            itemBuilder: (_, int index) {
              final Song song = songs[index];
              return ListTile(
                leading: CircleAvatar(child: Text('${index + 1}')),
                title: new Text(song.title),
                subtitle: new Text(song.artist),
                onTap: () => play(song, 1.0),
              );
            },
          );
        } else {
          return CircularProgressIndicator();
        }
      },
    );
  }
}

music.dart

import 'dart:async';

import 'package:flutter/services.dart';

const MethodChannel _channel = const MethodChannel('music');

Future<bool> isLicensed() async {
  final bool result = await _channel.invokeMethod('isLicensed');
  return result;
}

Future<List<Song>> songs() async {
  final List<dynamic> songs = await _channel.invokeMethod('getSongs');
  return songs.map(Song.fromJson).toList();
}

Future<void> play(Song song, double volume) async {
  try {
    await _channel.invokeMethod('play', <String, dynamic>{
      'song': song.id,
      'volume': volume,
    });
  } on PlatformException catch (e) {
    throw 'Unable to play ${song.title}: ${e.message}';
  }
}

class Song {
  Song(this.id, this.title, this.artist);

  final String id;
  final String title;
  final String artist;

  static Song fromJson(dynamic json) {
    return new Song(json['id'], json['title'], json['artist']);
  }
}

The code compiles nicely with an earlier version (Flutter beta):

[✓] Flutter (Channel beta, v0.2.3, on Mac OS X 10.13.3 17D102, locale en-US)
    • Flutter version 0.2.3 at /Users/mravn/github/flutter
    • Framework revision 5a58b36e36 (3 weeks ago), 2018-03-13 13:20:13 -0700
    • Engine revision e61bb9ac3a
    • Dart version 2.0.0-dev.35.flutter-290c576264
@dgrove dgrove added the legacy-area-front-end Legacy: Use area-dart-model instead. label Apr 2, 2018
@dgrove dgrove added this to the Dart2 Beta 3 milestone Apr 2, 2018
@dgrove dgrove added crash Process exits with SIGSEGV, SIGABRT, etc. An unhandled exception is not a crash. P1 A high priority bug; for example, a single project is unusable or has many test failures labels Apr 2, 2018
@dgrove
Copy link
Contributor

dgrove commented Apr 2, 2018

Setting to P1 since it's a crash.

@JekCharlsonYu
Copy link
Contributor

closed as duplicate of #32737

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Process exits with SIGSEGV, SIGABRT, etc. An unhandled exception is not a crash. legacy-area-front-end Legacy: Use area-dart-model instead. P1 A high priority bug; for example, a single project is unusable or has many test failures
Projects
None yet
Development

No branches or pull requests

4 participants