dart2js -c, why can't List<double>.add() handle type 'double' ?

64 views
Skip to first unread message

Everton Marques

unread,
May 23, 2013, 6:19:01 PM5/23/13
to mi...@dartlang.org
The code below, compiled with "dart2js -c", issues the following error:

numbers.add: type 'Number' is not a subtype of type 'double'

Is this behavior correct? Why? Can anyone please shed some light?

Code:

void main() { 
  List<double> numbers = new List<double>();
  String s = "1.0";
  double d;
  try { d = double.parse(s); } catch (e) { print("double.parse: $e"); }
  try { numbers.add(d); } catch (e) { print("numbers.add: $e");}
  query("#sample_text_id").text = "s=$s d=$d numbers=$numbers";
}

Output:

s=1.0 d=1 numbers=[]

System:

Dart Editor version 0.5.9_r22879
Dart SDK version 0.5.9.0_r22879
Windows 7 on 64-bit

Thanks,
Everton

Peter Ahé

unread,
May 24, 2013, 1:23:14 AM5/24/13
to mi...@dartlang.org
This sounds like a bug. Would you mind reporting it at http://dartbug.com/new?

Cheers,
Peter 
--
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
 
 

Everton Marques

unread,
May 24, 2013, 2:12:44 AM5/24/13
to mi...@dartlang.org
Reply all
Reply to author
Forward
0 new messages