Repository navigation
Closed
Labels
P1A high priority bug; for example, a single project is unusable or has many test failuresA high priority bug; for example, a single project is unusable or has many test failureslegacy-area-front-endLegacy: Use area-dart-model instead.Legacy: Use area-dart-model instead.
Milestone
Description
Turning on constant_update_2018 flag and running flutter tests produces the following error:
Compiler message:
file:///usr/local/google/home/asiva/workspace/flutter-roll/flutter/packages/flut
ter/lib/src/painting/flutter_logo.dart:56:26: Error: Binary operator '=='
requires receiver constant 'FlutterLogoStyle {index: 0, #lib1::_name:
"FlutterLogoStyle.markOnly"}' of type 'Null', 'bool', 'int', 'double', or
'String', but was of type 'FlutterLogoStyle'.
- 'FlutterLogoStyle' is from 'package:flutter/src/painting/flutter_logo.dart'
('file:///usr/local/google/home/asiva/workspace/flutter-roll/flutter/packages/f
lutter/lib/src/painting/flutter_logo.dart').
_position = style == FlutterLogoStyle.markOnly ? 0.0 : style ==
FlutterLogoStyle.horizontal ? 1.0 : -1.0, // ignore:
CONST_EVAL_TYPE_BOOL_NUM_STRING
The relevant code is as follows:
import 'dart:math' as math;
import 'dart:typed_data';
import 'dart:ui' as ui show Gradient, TextBox, lerpDouble;
import 'package:flutter/foundation.dart';
import 'alignment.dart';
import 'basic_types.dart';
import 'box_fit.dart';
import 'decoration.dart';
import 'edge_insets.dart';
import 'image_provider.dart';
import 'text_painter.dart';
import 'text_span.dart';
import 'text_style.dart';
/// Possible ways to draw Flutter's logo.
enum FlutterLogoStyle {
/// Show only Flutter's logo, not the "Flutter" label.
///
/// This is the default behavior for [FlutterLogoDecoration] objects.
markOnly,
/// Show Flutter's logo on the left, and the "Flutter" label to its right.
horizontal,
/// Show Flutter's logo above the "Flutter" label.
stacked,
}
/// An immutable description of how to paint Flutter's logo.
class FlutterLogoDecoration extends Decoration {
/// Creates a decoration that knows how to paint Flutter's logo.
///
/// The [lightColor] and [darkColor] are used to fill the logo. The [style]
/// controls whether and where to draw the "Flutter" label. If one is shown,
/// the [textColor] controls the color of the label.
///
/// The [lightColor], [darkColor], [textColor], [style], and [margin]
/// arguments must not be null.
const FlutterLogoDecoration({
this.lightColor = const Color(0xFF42A5F5), // Colors.blue[400]
this.darkColor = const Color(0xFF0D47A1), // Colors.blue[900]
this.textColor = const Color(0xFF616161),
this.style = FlutterLogoStyle.markOnly,
this.margin = EdgeInsets.zero,
}) : assert(lightColor != null),
assert(darkColor != null),
assert(textColor != null),
assert(style != null),
assert(margin != null),
_position = style == FlutterLogoStyle.markOnly ? 0.0 : style == FlutterLo
goStyle.horizontal ? 1.0 : -1.0, // ignore: CONST_EVAL_TYPE_BOOL_NUM_STRING
// (see https://github.com/dart-lang/sdk/issues/26980 for details about t
hat ignore statement)
_opacity = 1.0;
const FlutterLogoDecoration._(this.lightColor, this.darkColor, this.textColor,
this.style, this.margin, this._position, this._opacity);
................
................
/// Whether and where to draw the "Flutter" text. By default, only the logo
/// itself is drawn.
// This property isn't actually used when painting. It's only really used to
// set the internal _position property.
final FlutterLogoStyle style;
..................
..................
}
Metadata
Metadata
Assignees
Labels
P1A high priority bug; for example, a single project is unusable or has many test failuresA high priority bug; for example, a single project is unusable or has many test failureslegacy-area-front-endLegacy: Use area-dart-model instead.Legacy: Use area-dart-model instead.
Activity
a-siva commentedon Apr 11, 2019
Was able to reduce the test as follows
This produces the following error when constant__update_2018 flag is used
Without the flag it runs fine:
kmillikin commentedon Apr 11, 2019
This is invalid code, that's why the analyzer is told to shut up with
// ignore: CONST_EVAL_TYPE_BOOL_NUM_STRING.The error message we give seems kind of cryptic, but the important part is that the spec requires "receiver ... of type 'Null', 'bool', 'int', 'double', or 'String', but was of type 'FlutterLogoStyle'".
If we had a spec change, it would be easy enough to change the constant evaluator.
/cc @lrhn
kmillikin commentedon Apr 11, 2019
This is really a duplicate of #26980.
kmillikin commentedon Apr 11, 2019
The front-end constant evaluator fixes a bug in the VM (that it accepted this code). Flutter will see it as a regression because the Dart platform they were using previously allowed this code. This is despite the fact that it was knowingly exploiting a VM bug.
I'm not sure how we want to proceed from here. The workaround in Flutter code is to use
identicalinstead ofoperator==.I talked to @lrhn and we're not going to get a spec update for this issue for Dart 2.3.
We could provide a flag that the VM target could use to instruct us to be bug compatible with the previous behavior, and allow this comparison. I'd like to do that as a very last resort and try to fix Flutter first.
stereotype441 commentedon Apr 11, 2019
FYI, some related bugs:
sigmundch commentedon Apr 11, 2019
@a-siva I see that your pull request was merged, is it OK to close this issue now?
a-siva commentedon Apr 11, 2019
Flutter code has been fixed.
Fix enum instances comparison to use `equality ==` since dart has the…
Replace more enum instances comparison to use `equality ==` instead o…
`[cupertino_ui]` replace identical checks with equality when dealing …
`[cupertino_ui]` replace identical checks with equality when dealing …
`[material_ui]` replace identical checks with equality when dealing w…
`[cupertino_ui]` replace identical checks with equality when dealing …
`[material_ui]` replace identical checks with equality when dealing w…
Update more enum instances comparison to use equality == since dart h…