Giter Club home page Giter Club logo

Comments (2)

kevmoo avatar kevmoo commented on July 17, 2024

Here's the fun bit. With this diff, no compiler crash:

diff --git a/lib/src/sokoban_view/components/grided.dart b/lib/src/sokoban_view/components/grided.dart
index 198775a..e28a176 100644
--- a/lib/src/sokoban_view/components/grided.dart
+++ b/lib/src/sokoban_view/components/grided.dart
@@ -25,6 +25,6 @@ mixin GridElement {
   Vector2 getPosition() => Vector2(
       (gridPosition.x * gridPixelDimensions.x) + gridPixelOffset.x,
       (gridPosition.y * gridPixelDimensions.y) + gridPixelOffset.y);
-  double getGridValue() => (gridPosition.y * 13.0) + gridPosition.x;
-  int getLayeredGridValue() => getGridValue().toInt() + (layer * 200);
+  int getGridValue() => ((gridPosition.y * 13.0) + gridPosition.x).toInt();
+  int getLayeredGridValue() => getGridValue() + (layer * 200);
 }
diff --git a/lib/src/sokoban_view/components/world.dart b/lib/src/sokoban_view/components/world.dart
index c68e5a8..c2460f3 100644
--- a/lib/src/sokoban_view/components/world.dart
+++ b/lib/src/sokoban_view/components/world.dart
@@ -158,7 +158,7 @@ class SokobanWorld extends World with HasGameRef {
       var initialIdx = int.parse(split[1]);
       var nextIdx = int.parse(split[2]);
       var goalHit = bool.parse(split[3]);
-      var gridValue = box.getGridValue() as int;
+      var gridValue = box.getGridValue();
 
       logger.i('box $idx $gridValue');
       if (gridValue == initialIdx) {
@@ -183,7 +183,7 @@ class SokobanWorld extends World with HasGameRef {
 
     for (var idx = 0; idx < batteries.length; idx++) {
       var battery = batteries[idx];
-      var gridValue = battery.getGridValue() as int;
+      var gridValue = battery.getGridValue();
 
       if (gridValue == initialIdx) {
         battery.hide();

from sdk.

osa1 avatar osa1 commented on July 17, 2024

Smaller repro:

class Num {
  final double x;

  Num(this.x);

  double getX() => x;
}

void main() {
  final num = Num(0.0);
  var value = num.getX() as int;
  print(value);
}

Compile with --omit-implicit-checks --omit-explicit-checks.

from sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.