{"action":"created","issue":{"url":"https://api.github.com/repos/dart-lang/sdk/issues/26462","repository_url":"https://api.github.com/repos/dart-lang/sdk","labels_url":"https://api.github.com/repos/dart-lang/sdk/issues/26462/labels{/name}","comments_url":"https://api.github.com/repos/dart-lang/sdk/issues/26462/comments","events_url":"https://api.github.com/repos/dart-lang/sdk/issues/26462/events","html_url":"https://github.com/dart-lang/sdk/issues/26462","id":155054604,"number":26462,"title":"async doWhile stops iteration when f returns non-Future","user":{"login":"ngolovleva","id":15155393,"avatar_url":"https://avatars.githubusercontent.com/u/15155393?v=3","gravatar_id":"","url":"https://api.github.com/users/ngolovleva","html_url":"https://github.com/ngolovleva","followers_url":"https://api.github.com/users/ngolovleva/followers","following_url":"https://api.github.com/users/ngolovleva/following{/other_user}","gists_url":"https://api.github.com/users/ngolovleva/gists{/gist_id}","starred_url":"https://api.github.com/users/ngolovleva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ngolovleva/subscriptions","organizations_url":"https://api.github.com/users/ngolovleva/orgs","repos_url":"https://api.github.com/users/ngolovleva/repos","events_url":"https://api.github.com/users/ngolovleva/events{/privacy}","received_events_url":"https://api.github.com/users/ngolovleva/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dart-lang/sdk/labels/area-library","name":"area-library","color":"c7def8"},{"url":"https://api.github.com/repos/dart-lang/sdk/labels/docs-api","name":"docs-api","color":"d4c5f9"},{"url":"https://api.github.com/repos/dart-lang/sdk/labels/library-async","name":"library-async","color":"d4c5f9"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-05-16T15:30:49Z","updated_at":"2016-05-18T12:25:52Z","closed_at":"2016-05-18T12:25:52Z","body":"According to https://api.dartlang.org/stable/1.16.0/dart-async/Future/doWhile.html \r\n\r\n\"Future doWhile(dynamic f())\r\n. . .\r\nThe function f may return either a bool or a Future that completes to a bool. If it returns a non-Future, iteration continues immediately. \"\r\n\r\nHowever, if f returns a non-Future (new Object() in the test below), iteration stops.\r\n\r\n```dart\r\nimport \"dart:async\";\r\n\r\nconst N = 5;\r\n\r\nmain() {\r\n  int num = 0;\r\n\r\n  Future f() {\r\n    print(\"-- $num\");\r\n    if (num == 2) {\r\n      num++;\r\n      return new Object();\r\n    }\r\n    Completer c = new Completer();\r\n    if (num < N) {\r\n      num++;\r\n      c.complete(true);\r\n      return c.future;\r\n    } else {\r\n      c.complete(false);\r\n      return c.future;\r\n    }\r\n  }\r\n\r\n  Future future = Future.doWhile(f);\r\n\r\n  future.then((fValue) {\r\n    print(\"num $num\");\r\n  })\r\n  .catchError((e) {\r\n    print(\"catchError: $e\");\r\n  });\r\n}\r\n```\r\ndart test.dart \r\n-- 0\r\n-- 1\r\n-- 2\r\nnum 3\r\n\r\nTested on Dart VM version: 1.17.0-dev.3.0 (Wed May 11 01:53:34 2016) on \"linux_x64\"\r\n"},"comment":{"url":"https://api.github.com/repos/dart-lang/sdk/issues/comments/220010491","html_url":"https://github.com/dart-lang/sdk/issues/26462#issuecomment-220010491","issue_url":"https://api.github.com/repos/dart-lang/sdk/issues/26462","id":220010491,"user":{"login":"lrhn","id":4865287,"avatar_url":"https://avatars.githubusercontent.com/u/4865287?v=3","gravatar_id":"","url":"https://api.github.com/users/lrhn","html_url":"https://github.com/lrhn","followers_url":"https://api.github.com/users/lrhn/followers","following_url":"https://api.github.com/users/lrhn/following{/other_user}","gists_url":"https://api.github.com/users/lrhn/gists{/gist_id}","starred_url":"https://api.github.com/users/lrhn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lrhn/subscriptions","organizations_url":"https://api.github.com/users/lrhn/orgs","repos_url":"https://api.github.com/users/lrhn/repos","events_url":"https://api.github.com/users/lrhn/events{/privacy}","received_events_url":"https://api.github.com/users/lrhn/received_events","type":"User","site_admin":false},"created_at":"2016-05-18T12:25:52Z","updated_at":"2016-05-18T12:25:52Z","body":"Documentation has now been improved."}}