Discussion:
[dart-misc] Strong mode
Don Olmstead
2015-10-28 23:05:20 UTC
Permalink
On the Slack channel we found out how to enable Strong Mode with the newest
dev channel from directions on https://pub.dartlang.org/packages/analyzer.
It definitely is complaining a lot more with Dart code which is fine by me.

The real question I wanted to ask is how aggressively should we be posting
bugs about strong mode? I enabled strong mode and the following code popped
up as a warning.

var metadata = await readMetadata(); // This returns a Map<String,
List<String>>

metadata.forEach((id, parameters) {
translations[id] = new Translation(parameters); // Parameters is a
List<String>
});


If I add List<String> next to parameters then no warnings. Without it I get
`parameters (dynamic) will need runtime check to cast to type List<String>`

Map seems to be typed properly with
forEach, https://api.dartlang.org/133591/dart-core/Map/forEach.html, so I'm
guessing its a strong mode problem.
--
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.
'Vijay Menon' via Dart Misc
2015-10-28 23:46:55 UTC
Permalink
Please do file bugs - this kind of feedback is super useful to us.

thanks!

Vijay
Post by Don Olmstead
On the Slack channel we found out how to enable Strong Mode with the
newest dev channel from directions on
https://pub.dartlang.org/packages/analyzer. It definitely is complaining
a lot more with Dart code which is fine by me.
The real question I wanted to ask is how aggressively should we be posting
bugs about strong mode? I enabled strong mode and the following code popped
up as a warning.
var metadata = await readMetadata(); // This returns a Map<String,
List<String>>
metadata.forEach((id, parameters) {
translations[id] = new Translation(parameters); // Parameters is a
List<String>
});
If I add List<String> next to parameters then no warnings. Without it I
get `parameters (dynamic) will need runtime check to cast to type
List<String>`
Map seems to be typed properly with forEach,
https://api.dartlang.org/133591/dart-core/Map/forEach.html, so I'm
guessing its a strong mode problem.
--
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.
Don Olmstead
2015-10-29 00:05:39 UTC
Permalink
Any particular labeling that you guys want?

Also as a corollary what core libs work fully in strong mode? And is there
a tracking bug there?

On Wednesday, October 28, 2015, 'Vijay Menon' via Dart Misc <
Post by 'Vijay Menon' via Dart Misc
Please do file bugs - this kind of feedback is super useful to us.
thanks!
Vijay
Post by Don Olmstead
On the Slack channel we found out how to enable Strong Mode with the
newest dev channel from directions on
https://pub.dartlang.org/packages/analyzer. It definitely is complaining
a lot more with Dart code which is fine by me.
The real question I wanted to ask is how aggressively should we be
posting bugs about strong mode? I enabled strong mode and the following
code popped up as a warning.
var metadata = await readMetadata(); // This returns a Map<String,
List<String>>
metadata.forEach((id, parameters) {
translations[id] = new Translation(parameters); // Parameters is a
List<String>
});
If I add List<String> next to parameters then no warnings. Without it I
get `parameters (dynamic) will need runtime check to cast to type
List<String>`
Map seems to be typed properly with forEach,
https://api.dartlang.org/133591/dart-core/Map/forEach.html, so I'm
guessing its a strong mode problem.
--
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
--
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.
Don Olmstead
2015-10-29 01:47:33 UTC
Permalink
One other question since I'm running my projects through it and seeing what
pops up.

So I have a Stream that I'm using .map on to convert it from a Map to a
PODO. Code that strong mode doesn't complain about looks like this.

Stream<Model> query(FluentQuery<Model> query) {
return connection.query(query.query)
.map((value) => decoder.convert(value)) as Stream<Model>;
}


Since generic methods aren't there map returns a Stream without a type. So
is it okay to just add the cast or should I be doing something different?
Seems like the majority of fixes for strong mode on my code seem to be
adding a bunch of casts to things.
--
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.
'Vijay Menon' via Dart Misc
2015-10-29 02:25:16 UTC
Permalink
Re labels: we use Analyzer-StrongMode.

We're actively working on generic methods (annotation-based for now) to
properly handle cases like the below. A cast isn't ideal here. I'd either
ignore that warning for now or add a TODO to remove it later.
Post by Don Olmstead
One other question since I'm running my projects through it and seeing
what pops up.
So I have a Stream that I'm using .map on to convert it from a Map to a
PODO. Code that strong mode doesn't complain about looks like this.
Stream<Model> query(FluentQuery<Model> query) {
return connection.query(query.query)
.map((value) => decoder.convert(value)) as Stream<Model>;
}
Since generic methods aren't there map returns a Stream without a type. So
is it okay to just add the cast or should I be doing something different?
Seems like the majority of fixes for strong mode on my code seem to be
adding a bunch of casts to things.
--
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.
Anders Holmgren
2015-10-29 04:19:48 UTC
Permalink
hopefully this gives a strong push for getting generic methods in the language ASAP. OK so I may be biased as it has been my #1 wanted feature pretty much since I started Dart but ...
--
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-29 05:24:36 UTC
Permalink
Generic methods would already be very useful if only the analyzer supports them for static analysis, without any runtime support (reification)
Post by Anders Holmgren
hopefully this gives a strong push for getting generic methods in the language ASAP. OK so I may be biased as it has been my #1 wanted feature pretty much since I started Dart but ...
--
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-30 11:00:33 UTC
Permalink
A couple more examples of strong analyzer wanting explicit casts:

1. List.map returns Iterable<dynamic>
List<String> getWords() {
var data = "foo , bar, buz ";
return data.split(",").map((e) => e.trim()).toList();
}

Warning:(6, 10) data.split(",").map((e) => e.trim()).toList()
(List<dynamic>) will need runtime check to cast to type List<String>


2. Stream<T>.transform(StreamTransformer<T, S>) returns Stream<dynamic>
import 'dart:async';
import 'dart:io';

void main() {
var input = new File("data/input.bin").openRead();
var output = new File("data/output.bin").openWrite();
output.addStream(input.transform(new MyTransformer()));
}

class MyTransformer implements StreamTransformer<List<int>, List<int>> {
Stream<List<int>> bind(Stream<List<int>> stream) =>
new Stream<List<int>>.eventTransformed(
stream, (EventSink<List<int>> sink) => sink);
}

Warning:(12, 20) input.transform(new MyTransformer()) (Stream<dynamic>)
will need runtime check to cast to type Stream<List<int>>
Post by 'Vijay Menon' via Dart Misc
Re labels: we use Analyzer-StrongMode.
We're actively working on generic methods (annotation-based for now) to
properly handle cases like the below. A cast isn't ideal here. I'd either
ignore that warning for now or add a TODO to remove it later.
Post by Don Olmstead
One other question since I'm running my projects through it and seeing
what pops up.
So I have a Stream that I'm using .map on to convert it from a Map to a
PODO. Code that strong mode doesn't complain about looks like this.
Stream<Model> query(FluentQuery<Model> query) {
return connection.query(query.query)
.map((value) => decoder.convert(value)) as Stream<Model>;
}
Since generic methods aren't there map returns a Stream without a type.
So is it okay to just add the cast or should I be doing something
different? Seems like the majority of fixes for strong mode on my code seem
to be adding a bunch of casts to things.
--
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.
'John Messerly' via Dart Misc
2015-10-30 17:39:22 UTC
Permalink
Post by Alexey Knyazev
1. List.map returns Iterable<dynamic>
List<String> getWords() {
var data = "foo , bar, buz ";
return data.split(",").map((e) => e.trim()).toList();
}
Warning:(6, 10) data.split(",").map((e) => e.trim()).toList()
(List<dynamic>) will need runtime check to cast to type List<String>
yup, these result from a couple of known
<https://github.com/dart-lang/dev_compiler/issues/203> issues
<https://github.com/dart-lang/dev_compiler/issues/28>. We're working on
both of them.
Post by Alexey Knyazev
2. Stream<T>.transform(StreamTransformer<T, S>) returns Stream<dynamic>
import 'dart:async';
import 'dart:io';
void main() {
var input = new File("data/input.bin").openRead();
var output = new File("data/output.bin").openWrite();
output.addStream(input.transform(new MyTransformer()));
}
class MyTransformer implements StreamTransformer<List<int>, List<int>> {
Stream<List<int>> bind(Stream<List<int>> stream) =>
new Stream<List<int>>.eventTransformed(
stream, (EventSink<List<int>> sink) => sink);
}
Warning:(12, 20) input.transform(new MyTransformer()) (Stream<dynamic>)
will need runtime check to cast to type Stream<List<int>>
Post by 'Vijay Menon' via Dart Misc
Re labels: we use Analyzer-StrongMode.
We're actively working on generic methods (annotation-based for now) to
properly handle cases like the below. A cast isn't ideal here. I'd either
ignore that warning for now or add a TODO to remove it later.
Post by Don Olmstead
One other question since I'm running my projects through it and seeing
what pops up.
So I have a Stream that I'm using .map on to convert it from a Map to a
PODO. Code that strong mode doesn't complain about looks like this.
Stream<Model> query(FluentQuery<Model> query) {
return connection.query(query.query)
.map((value) => decoder.convert(value)) as Stream<Model>;
}
Since generic methods aren't there map returns a Stream without a type.
So is it okay to just add the cast or should I be doing something
different? Seems like the majority of fixes for strong mode on my code seem
to be adding a bunch of casts to things.
--
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
--
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.
Don Olmstead
2015-10-30 18:21:57 UTC
Permalink
Yea generic methods will sort those out.

On Fri, Oct 30, 2015 at 10:39 AM, 'John Messerly' via Dart Misc <
Post by 'John Messerly' via Dart Misc
Post by Alexey Knyazev
1. List.map returns Iterable<dynamic>
List<String> getWords() {
var data = "foo , bar, buz ";
return data.split(",").map((e) => e.trim()).toList();
}
Warning:(6, 10) data.split(",").map((e) => e.trim()).toList()
(List<dynamic>) will need runtime check to cast to type List<String>
yup, these result from a couple of known
<https://github.com/dart-lang/dev_compiler/issues/203> issues
<https://github.com/dart-lang/dev_compiler/issues/28>. We're working on
both of them.
Post by Alexey Knyazev
2. Stream<T>.transform(StreamTransformer<T, S>) returns Stream<dynamic>
import 'dart:async';
import 'dart:io';
void main() {
var input = new File("data/input.bin").openRead();
var output = new File("data/output.bin").openWrite();
output.addStream(input.transform(new MyTransformer()));
}
class MyTransformer implements StreamTransformer<List<int>, List<int>> {
Stream<List<int>> bind(Stream<List<int>> stream) =>
new Stream<List<int>>.eventTransformed(
stream, (EventSink<List<int>> sink) => sink);
}
Warning:(12, 20) input.transform(new MyTransformer()) (Stream<dynamic>)
will need runtime check to cast to type Stream<List<int>>
Post by 'Vijay Menon' via Dart Misc
Re labels: we use Analyzer-StrongMode.
We're actively working on generic methods (annotation-based for now) to
properly handle cases like the below. A cast isn't ideal here. I'd either
ignore that warning for now or add a TODO to remove it later.
Post by Don Olmstead
One other question since I'm running my projects through it and seeing
what pops up.
So I have a Stream that I'm using .map on to convert it from a Map to a
PODO. Code that strong mode doesn't complain about looks like this.
Stream<Model> query(FluentQuery<Model> query) {
return connection.query(query.query)
.map((value) => decoder.convert(value)) as Stream<Model>;
}
Since generic methods aren't there map returns a Stream without a type.
So is it okay to just add the cast or should I be doing something
different? Seems like the majority of fixes for strong mode on my code seem
to be adding a bunch of casts to things.
--
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
--
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
--
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...