Discussion:
[dart-misc] Await and function parameters
Alexey Knyazev
2015-10-02 15:08:09 UTC
Permalink
Why are function parameters treated differently when it was called with
await instead of using '.then'? For example, this code
import 'dart:async';

main() async {
Future foo(int a1, int a2) {
print("from foo: $a1 $a2");
return new Future.value();
}

int a = 0;

await foo(a++, a++);
print("after await foo: $a");

a = 0;
foo(a++, a++).then((_) {
print("after foo.then: $a");
});
}

prints
from foo: 0 0
after await foo: 1
from foo: 0 1
after foo.then: 2
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Matthias Hausner' via Dart Misc
2015-10-02 15:50:56 UTC
Permalink
This looks like a bug to me. Can you please report it at dartbug.com?

Thank you,

Matthias
Post by Alexey Knyazev
Why are function parameters treated differently when it was called with
await instead of using '.then'? For example, this code
import 'dart:async';
main() async {
Future foo(int a1, int a2) {
print("from foo: $a1 $a2");
return new Future.value();
}
int a = 0;
await foo(a++, a++);
print("after await foo: $a");
a = 0;
foo(a++, a++).then((_) {
print("after foo.then: $a");
});
}
prints
from foo: 0 0
after await foo: 1
from foo: 0 1
after foo.then: 2
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Günter Zöchbauer
2015-10-02 16:42:57 UTC
Permalink
Works fine in JS https://dartpad.dartlang.org/040571aae27081d171ba but can
reproduce on local VM
Dart VM version: 1.13.0-edge.33b037125fbf5e8319a99fd5e5700441c921efde (Mon
Sep 14 18:13:24 2015) on "linux_x64"
Post by Alexey Knyazev
Why are function parameters treated differently when it was called with
await instead of using '.then'? For example, this code
import 'dart:async';
main() async {
Future foo(int a1, int a2) {
print("from foo: $a1 $a2");
return new Future.value();
}
int a = 0;
await foo(a++, a++);
print("after await foo: $a");
a = 0;
foo(a++, a++).then((_) {
print("after foo.then: $a");
});
}
prints
from foo: 0 0
after await foo: 1
from foo: 0 1
after foo.then: 2
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Matthias Hausner' via Dart Misc
2015-10-02 23:03:41 UTC
Permalink
Bug filed or not, here's the fix:

https://codereview.chromium.org/1382123003/
Post by Günter Zöchbauer
Works fine in JS https://dartpad.dartlang.org/040571aae27081d171ba but
can reproduce on local VM
Dart VM version: 1.13.0-edge.33b037125fbf5e8319a99fd5e5700441c921efde (Mon
Sep 14 18:13:24 2015) on "linux_x64"
Post by Alexey Knyazev
Why are function parameters treated differently when it was called with
await instead of using '.then'? For example, this code
import 'dart:async';
main() async {
Future foo(int a1, int a2) {
print("from foo: $a1 $a2");
return new Future.value();
}
int a = 0;
await foo(a++, a++);
print("after await foo: $a");
a = 0;
foo(a++, a++).then((_) {
print("after foo.then: $a");
});
}
prints
from foo: 0 0
after await foo: 1
from foo: 0 1
after foo.then: 2
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Alexey Knyazev
2015-10-02 23:53:34 UTC
Permalink
Thanks, bug was here
https://github.com/dart-lang/sdk/issues/24488
Post by 'Matthias Hausner' via Dart Misc
https://codereview.chromium.org/1382123003/
Post by Günter Zöchbauer
Works fine in JS https://dartpad.dartlang.org/040571aae27081d171ba but
can reproduce on local VM
Dart VM version: 1.13.0-edge.33b037125fbf5e8319a99fd5e5700441c921efde
(Mon Sep 14 18:13:24 2015) on "linux_x64"
Post by Alexey Knyazev
Why are function parameters treated differently when it was called with
await instead of using '.then'? For example, this code
import 'dart:async';
main() async {
Future foo(int a1, int a2) {
print("from foo: $a1 $a2");
return new Future.value();
}
int a = 0;
await foo(a++, a++);
print("after await foo: $a");
a = 0;
foo(a++, a++).then((_) {
print("after foo.then: $a");
});
}
prints
from foo: 0 0
after await foo: 1
from foo: 0 1
after foo.then: 2
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Loading...