Skip to content

[ddc] error on type checks for records #52480

Description

@treeplate
void main() {
  TowerArea towerArea = TowerArea();
  towerArea.tick();
  print('success');
  //runApp(const MyApp());
}

class TowerArea {
  final List<(double, double)> coins = [(0, 0)];

  void tick() {
    (double, double) coin = coins.first;
    coins[0] = (coin.$1, coin.$2 + .01);
  }
}

In DartPad, this prints success.
In native, this prints success.
In Flutter for Web, this throws the following error:

Error: Expected a value of type '(double, double)', but got one of type '(int, double)'
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 294:49      throw_
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 127:3       castError
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 738:12  cast
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart 2319:12      as
dart-sdk/lib/_internal/js_dev_runtime/private/js_array.dart 596:34                _set]
packages/<your package>/main.dart 15:10                                                tick
packages/<your package>/main.dart 5:12                                                 main$
web_entrypoint.dart 24:31                                                         <fn>
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 570:37  _checkAndCall
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 575:39  dcall
lib/ui/initialization.dart 77:15                                                  <fn>
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50                <fn>
dart-sdk/lib/async/zone.dart 1661:54                                              runUnary
dart-sdk/lib/async/future_impl.dart 153:18                                        handleValue
dart-sdk/lib/async/future_impl.dart 837:44                                        handleValueCallback
dart-sdk/lib/async/future_impl.dart 866:13                                        _propagateToListeners
dart-sdk/lib/async/future_impl.dart 638:5                                         [_completeWithValue]
dart-sdk/lib/async/future_impl.dart 712:7                                         callback
dart-sdk/lib/async/schedule_microtask.dart 40:11                                  _microtaskLoop
dart-sdk/lib/async/schedule_microtask.dart 49:5                                   _startMicrotaskLoop
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 181:15               <fn>

I'm using MacOS/Chrome however I have also tested on Windows10/Edge with similar results.
flutter --version

Flutter 3.11.0-11.0.pre.8 • channel master • https://github.com/flutter/flutter.git
Framework • revision 343718945b (6 hours ago) • 2023-05-22 14:11:18 -0400
Engine • revision e04c14786d
Tools • Dart 3.1.0 (build 3.1.0-129.0.dev) • DevTools 2.23.1

dart --version
Dart SDK version: 3.1.0-129.0.dev (dev) (Fri May 19 12:10:06 2023 -0700) on "macos_arm64"

Metadata

Metadata

Assignees

Labels

P1A high priority bug; for example, a single project is unusable or has many test failuresarea-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.web-dev-compiler

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions