Skip to content

Failures on Add record-related wait extensions on Future tuples. #51910

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
lrhn opened this issue Mar 30, 2023 · 1 comment
Closed

Failures on Add record-related wait extensions on Future tuples. #51910

lrhn opened this issue Mar 30, 2023 · 1 comment
Assignees
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. P1 A high priority bug; for example, a single project is unusable or has many test failures type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js

Comments

@lrhn
Copy link
Member

lrhn commented Mar 30, 2023

There are new test failures on Add record-related wait extensions on Future tuples..

The tests

lib/async/future_record_extension_test RuntimeError (expected Pass)

are failing on configurations

dart2js-hostasserts-linux-chrome-unsound

The error message is

Type '(JSInt, JSBool)' is not a subtype of type 'FutureOr<(int, bool)>?'

which suggests an error related to record types, internal types and FutureOr.
Possibly related to: #51731

The full error report is:

/========================================================================================\
| lib/async/future_record_extension_test is new and failed (RuntimeError, expected Pass) |
\========================================================================================/

--- Command "dart2js" (took 07.000290s):
DART_CONFIGURATION=ReleaseX64 sdk/bin/dart2js_developer -Dtest_runner.configuration=dart2js-hostasserts-linux-d8 --sound-null-safety --test-mode --packages=/b/s/w/ir/.dart_tool/package_config.json /b/s/w/ir/tests/lib/async/future_record_extension_test.dart --sound-null-safety --out=/b/s/w/ir/out/ReleaseX64/generated_compilations/dart2js-hostasserts-linux-d8/tests_lib_async_future_record_extension_test/future_record_extension_test.js

exit code:
0

stdout:
Hint: When run on the command-line, the compiled output might require a preamble file located in:
  <sdk>/lib/_internal/js_runtime/lib/preambles.
Compiled 9,775,330 characters Dart to 243,576 characters JavaScript in 7.22 seconds using 486.145 MB of memory
Dart file tests/lib/async/future_record_extension_test.dart compiled to JavaScript: out/ReleaseX64/generated_compilations/dart2js-hostasserts-linux-d8/tests_lib_async_future_record_extension_test/future_record_extension_test.js

--- Command "d8" (took 74ms):
DART_CONFIGURATION=ReleaseX64 /b/s/w/ir/third_party/d8/linux/d8 /b/s/w/ir/sdk/lib/_internal/js_runtime/lib/preambles/d8.js /b/s/w/ir/out/ReleaseX64/generated_compilations/dart2js-hostasserts-linux-d8/tests_lib_async_future_record_extension_test/future_record_extension_test.js

exit code:
1

stdout:
unittest-suite-wait-for-done
/b/s/w/ir/sdk/lib/_internal/js_runtime/lib/preambles/d8.js:263: TypeError: Record (2, true): type '(JSInt, JSBool)' is not a subtype of type 'FutureOr<(int, bool)>?'
          throw e;
          ^
TypeError: Record (2, true): type '(JSInt, JSBool)' is not a subtype of type 'FutureOr<(int, bool)>?'
    at Object.wrapException (/b/s/w/ir/out/ReleaseX64/generated_compilations/dart2js-hostasserts-linux-d8/tests_lib_async_future_record_extension_test/future_record_extension_test.js:329:17)
    at Object._failedAsCheck (/b/s/w/ir/out/ReleaseX64/generated_compilations/dart2js-hostasserts-linux-d8/tests_lib_async_future_record_extension_test/future_record_extension_test.js:1269:15)
    at Rti._generalNullableAsCheckImplementation [as _as] (/b/s/w/ir/out/ReleaseX64/generated_compilations/dart2js-hostasserts-linux-d8/tests_lib_async_future_record_extension_test/future_record_extension_test.js:1266:9)
    at Rti._installSpecializedAsCheck (/b/s/w/ir/out/ReleaseX64/generated_compilations/dart2js-hostasserts-linux-d8/tests_lib_async_future_record_extension_test/future_record_extension_test.js:1194:22)
    at _SyncCompleter.complete$1 (/b/s/w/ir/out/ReleaseX64/generated_compilations/dart2js-hostasserts-linux-d8/tests_lib_async_future_record_extension_test/future_record_extension_test.js:5171:25)
    at FutureRecord2_get_wait_closure.call$1 (/b/s/w/ir/out/ReleaseX64/generated_compilations/dart2js-hostasserts-linux-d8/tests_lib_async_future_record_extension_test/future_record_extension_test.js:4993:12)
    at _FutureResult__waitAll_onReady.call$1 (/b/s/w/ir/out/ReleaseX64/generated_compilations/dart2js-hostasserts-linux-d8/tests_lib_async_future_record_extension_test/future_record_extension_test.js:5150:24)
    at _FutureResult._onValue$1 (/b/s/w/ir/out/ReleaseX64/generated_compilations/dart2js-hostasserts-linux-d8/tests_lib_async_future_record_extension_test/future_record_extension_test.js:5132:20)
    at tear_off.<anonymous> (/b/s/w/ir/out/ReleaseX64/generated_compilations/dart2js-hostasserts-linux-d8/tests_lib_async_future_record_extension_test/future_record_extension_test.js:622:45)
    at _RootZone.runUnary$2$2 (/b/s/w/ir/out/ReleaseX64/generated_compilations/dart2js-hostasserts-linux-d8/tests_lib_async_future_record_extension_test/future_record_extension_test.js:5567:18)

Deobfuscated error and stack:
TypeError: Record (2, true): type '(JSInt, JSBool)' is not a subtype of type 'FutureOr<(int, bool)>?'
    at wrapException                             org-dartlang-sdk:///lib/_internal/js_runtime/lib/js_helper.dart 1194:37
    at _failedAsCheck                            org-dartlang-sdk:///lib/_internal/js_shared/lib/rti.dart 1164:3
    at _generalNullableAsCheckImplementation     org-dartlang-sdk:///lib/_internal/js_shared/lib/rti.dart 1159:3
    at _installSpecializedAsCheck                org-dartlang-sdk:///lib/_internal/js_shared/lib/rti.dart 1052:3
    at _SyncCompleter.complete                   org-dartlang-sdk:///lib/async/future_impl.dart 47:22
    at FutureRecord2|get#wait.<anonymous>        org-dartlang-sdk:///lib/async/future_extensions.dart 79:9
    at _FutureResult._waitAll.onReady            org-dartlang-sdk:///lib/async/future_extensions.dart 527:9
    at _FutureResult._onValue                    org-dartlang-sdk:///lib/async/future_extensions.dart 508:12
    at Closure.fromTearOff                       org-dartlang-sdk:///lib/_internal/js_runtime/lib/js_helper.dart 2181:9
    at _RootZone.runUnary                        org-dartlang-sdk:///lib/async/zone.dart 1661:46
@lrhn lrhn added P1 A high priority bug; for example, a single project is unusable or has many test failures web-dart2js type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. labels Mar 30, 2023
@fishythefish
Copy link
Member

Repro:

import 'dart:async';

@pragma('dart2js:noInline')
T cast<T>(dynamic x) => x as T;

void main() {
  print(cast<FutureOr<(int, bool)>>((2, true)));
}

The issue seems to be that the Rti for (2, true) is _Record_2 rather than +(int, bool), so rather than doing recursive subtype checks on the record fields, we immediately fail the subtype check after recursing into the FutureOr argument type.

The constant pool contains: B.Record2_2_true = new A._Record_2(2, true);

Note that cast<(int, bool)>((2, true)) succeeds (I assume via a different mechanism than the full isSubtype check), which may have hidden the issue.

copybara-service bot pushed a commit that referenced this issue Mar 31, 2023
Bug: #51910
Change-Id: I0ee968a88e67279d1ced7e1f1126357b0e1bc6b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292260
Reviewed-by: Stephen Adams <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. P1 A high priority bug; for example, a single project is unusable or has many test failures type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js
Projects
None yet
Development

No branches or pull requests

3 participants