Skip to content
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

[dart2js] List.unmodifiable fails to run on web #59790

Open
sunarya-thito opened this issue Dec 21, 2024 · 0 comments
Open

[dart2js] List.unmodifiable fails to run on web #59790

sunarya-thito opened this issue Dec 21, 2024 · 0 comments
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@sunarya-thito
Copy link

Steps to Reproduce

  1. Add this code
for (int i = 0; i < List.unmodifiable([]).length; i++) {}

for example

void main() {
  for (int i = 0; i < List.unmodifiable([]).length; i++) {}
  runApp(const MyApp());
}
  1. Run it with flutter web (on profile or release mode)
flutter run -d chrome --release

or you can also compile it with dart2js, which generate the js code below

    main() {
      var t1, i, result;
      result.$flags = 3;
      for (t1 = type$.dynamic, i = 0; result = A.List_List$from([], false, t1), i < result.length; ++i)
        ;
    }
  1. You will get this error
Uncaught Error: Error: Cannot set properties of undefined (setting '$flags')
    at main.dart:114:65
    at _wrapJsFunctionForAsync_closure.$protected (async_patch.dart:311:19)
    at _wrapJsFunctionForAsync_closure.call$2 (async_patch.dart:336:23)
    at _awaitOnObject_closure.call$1 (async_patch.dart:287:19)
    at _RootZone.runUnary$2$2 (zone.dart:1676:46)
    at _RootZone.runUnary$2 (zone.dart:1675:5)
    at _Future__propagateToListeners_handleValueCallback.call$0 (future_impl.dart:169:29)
    at Object._Future__propagateToListeners (future_impl.dart:931:13)
    at _Future._completeWithValue$1 (future_impl.dart:707:5)
    at _Future__asyncCompleteWithValue_closure.call$0 (future_impl.dart:777:7)

from

    main() {
      var t1, i, result;
      result.$flags = 3;
      for (t1 = type$.dynamic, i = 0; result = A.List_List$from([], false, t1), i < result.length; ++i)
        ;
    }

the result variable is not initialized with a value, but it tries to set its flag to 3

Dart Version

Dart SDK version: 3.6.0 (stable) (Thu Dec 5 07:46:24 2024 -0800) on "windows_x64"

I understand that the code isn't good or anything, but this shouldn't happen, right? I don't know what else it might cause, it runs perfectly on debug mode and other platform

@sunarya-thito sunarya-thito added the area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. label Dec 21, 2024
@lrhn lrhn added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

2 participants