Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Type checking is broken #6

Closed
DartBot opened this issue Oct 10, 2011 · 7 comments
Closed

Type checking is broken #6

DartBot opened this issue Oct 10, 2011 · 7 comments

Comments

@DartBot
Copy link

DartBot commented Oct 10, 2011

This issue was originally filed by benl@google.com


Use dartc_test to run:

bool foo(bool bar()) => bar();

bool bar() {}

main() {
  foo(bar);
}

with --enable_type_checks.

An error is thrown because the type of bar is not bool.

@DartBot
Copy link
Author

DartBot commented Oct 10, 2011

This comment was originally written by zundel@google.com


Just to be more clear, test.py —checked should turn on the type checks. Support was only added a few days ago. A fresh build and Ben got them to work in as much as they are supported.


Added Invalid label.

@DartBot
Copy link
Author

DartBot commented Oct 10, 2011

This comment was originally written by zundel@google.com


Added Accepted label.

@DartBot
Copy link
Author

DartBot commented Oct 10, 2011

This comment was originally written by zundel@google.com


bool foo(bool bar()) => bar();

bool baz() => true;

main() {
 Expect.equals(true, foo(baz));
}

When run with --enable_type_checks, this should produce no errors, but instead I get:

$ dart --enable_type_checks /tmp/foo3.dart
/tmp/dart_file:_tmp_foo3.dart3547703831643974851.js:403: [object Object]
  throw e;
        ^
[object Object]
    at $Dart$ThrowException (/tmp/dart_file:_tmp_foo3.dart3547703831643974851.js:401:11)
    at $te (/tmp/dart_file:_tmp_foo3.dart3547703831643974851.js:1701:3)
    at $chk (/tmp/dart_file:_tmp_foo3.dart3547703831643974851.js:1688:3)
    at unnamed7e6fa6$foo$member (/tmp/dart_file:_tmp_foo3.dart3547703831643974851.js:18591:3)
    at unnamed7e6fa6$main$member (/tmp/dart_file:_tmp_foo3.dart3547703831643974851.js:18616:35)
    at /tmp/dart_file:_tmp_foo3.dart3547703831643974851.js:1079:5
    at isolate$Isolate.run (/tmp/dart_file:_tmp_foo3.dart3547703831643974851.js:869:14)
    at isolate$IsolateEvent.process (/tmp/dart_file:_tmp_foo3.dart3547703831643974851.js:905:16)
    at isolate$doOneEventLoopIteration (/tmp/dart_file:_tmp_foo3.dart3547703831643974851.js:1038:11)
    at isolate$doRunEventLoop (/tmp/dart_file:_tmp_foo3.dart3547703831643974851.js:1054:26)
Execution failed.
Mapped stack trace:
    at UNMAPPED: /tmp/dart_file:_tmp_foo3.dart3547703831643974851.js:401:11 ($Dart$ThrowException)
    at UNMAPPED: /tmp/dart_file:_tmp_foo3.dart3547703831643974851.js:1701:3 ($te)
    at UNMAPPED: /tmp/dart_file:_tmp_foo3.dart3547703831643974851.js:1688:3 ($chk)
    at MAPPED : file:/tmp/foo3.dart/foo3.dart:1:10 (unnamed7e6fa6$foo$member)
    at MAPPED : file:/tmp/foo3.dart/foo3.dart:6:22 (unnamed7e6fa6$main$member)
    at UNMAPPED: /tmp/dart_file:_tmp_foo3.dart3547703831643974851.js:1079:5
    at UNMAPPED: /tmp/dart_file:_tmp_foo3.dart3547703831643974851.js:869:14 (isolate$Isolate.run)
    at UNMAPPED: /tmp/dart_file:_tmp_foo3.dart3547703831643974851.js:905:16 (isolate$IsolateEvent.process)
    at UNMAPPED: /tmp/dart_file:_tmp_foo3.dart3547703831643974851.js:1038:11 (isolate$doOneEventLoopIteration)
    at UNMAPPED: /tmp/dart_file:_tmp_foo3.dart3547703831643974851.js:1054:26 (isolate$doRunEventLoop)

V8 execution returned non-zero exit-code: 1


Set owner to jat@google.com.
Removed Priority-High label.
Added Priority-Medium, Area-Compiler labels.

@DartBot
Copy link
Author

DartBot commented Oct 25, 2011

This comment was originally written by mmendez@google.com


Set owner to fab...@google.com.
Added Started label.

@DartBot
Copy link
Author

DartBot commented Oct 25, 2011

This comment was originally written by jat@google.com


I have a fix I will be landing today that addresses this.

@DartBot
Copy link
Author

DartBot commented Oct 25, 2011

This comment was originally written by mmendez@google.com


Sorry, jat. I assumed that a patch was not forth coming. Assigned back to you.


Set owner to jat@google.com.

@DartBot
Copy link
Author

DartBot commented Nov 1, 2011

This comment was originally written by mmendez@google.com


JAT, I believe that your commit, http://code.google.com/p/dart/source/detail?r=975 fixed this issue. Please reopen if that is not the case.


Added Fixed label.

copybara-service bot pushed a commit that referenced this issue Oct 22, 2024
See: b/374689139.

https://dart-review.googlesource.com/c/sdk/+/390941 is blocking an SDK roll.

Root cause:


```
Action threw an exception: type 'ConstructorMember' is not a subtype of type 'ConstructorFragment' in type cast
#0      InterfaceTypeImpl.constructors2.<anonymous closure> (package:analyzer/src/dart/element/type.dart:569)
#1      MappedListIterable.elementAt (dart:_internal/iterable.dart:435)
#2      ListIterator.moveNext (dart:_internal/iterable.dart:364)
#3      new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:189)
#4      new _GrowableList.of (dart:core-patch/growable_array.dart:150)
#5      new List.of (dart:core-patch/array_patch.dart:39)
#6      ListIterable.toList (dart:_internal/iterable.dart:224)
#7      InterfaceTypeImpl.constructors2 (package:analyzer/src/dart/element/type.dart:570)
#8      _Visitor._hasConstConstructorInvocation (package:linter/src/rules/prefer_const_constructors_in_immutables.dart:110)
#9      _Visitor.visitConstructorDeclaration (package:linter/src/rules/prefer_const_constructors_in_immutables.dart:58)
```


To verify the fix locally:

```
  solo_test_X() async {
    await assertNoErrorsInCode(r'''
class A<T> {}
''');

    var A = findElement.class_('A').instantiate(
      typeArguments: [intType],
      nullabilitySuffix: NullabilitySuffix.none,
    );
    A.constructors2;
  }
```


Bug: b/374689139
Change-Id: I70034d938d840dc0c3939db27e7116164e4617e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391483
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
copybara-service bot pushed a commit that referenced this issue Feb 21, 2025
This test has a few independent calls to asyncExpectThrows which uses
asyncStart/asyncEnd. However, multiple top-level asyncStart/asyncEnd
are not allowed, which causes the following flaky error:

```
Unhandled exception:
Exception: Fatal: asyncStart() was called even though we are done with testing.. This is most likely a bug in your test.
#0      asyncStart (package:expect/async_helper.dart:53)
#1      asyncExpectThrows (package:expect/async_helper.dart:140)
#2      testMalformedAuthenticateHeaderWithAuthHandler.<anonymous closure> (file:///b/s/w/ir/cache/builder/sdk/tests/standalone/io/http_auth_digest_test.dart:345)
#3      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:951)
#4      Future._propagateToListeners (dart:async/future_impl.dart:980)
#5      Future._completeWithValue (dart:async/future_impl.dart:723)
#6      Future._asyncCompleteWithValue.<anonymous closure> (dart:async/future_impl.dart:807)
#7      _microtaskLoop (dart:async/schedule_microtask.dart:40)
#8      _startMicrotaskLoop (dart:async/schedule_microtask.dart:49)
#9      _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:128)
#10     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:195)

--- Re-run this test:
python3 tools/test.py -n vm-aot-ubsan-linux-release-x64 standalone/io/http_auth_digest_test
```

This change attempts to fix this by adding a top-level asyncStart/asyncEnd
and also asyncStart/asyncEnd to the server start/shutdown to
enclose each test case into asyncStart/asyncEnd and avoid printing
"unittest-suite-success" marker before all test cases are finished.

TEST=standalone/io/http_auth_digest_test

Change-Id: I950e7c6c09f5c2144da874ab3be3cd3a130d3790
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/411086
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
This issue was closed.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant