Why does this code "compile" without error (but will always fail at runtime)?

53 views
Skip to first unread message

Danny Tuppeny

unread,
May 5, 2015, 4:04:21 AM5/5/15
to mi...@dartlang.org
I would expect this code to give warnings in the IDE, but it doesn't (yet it will always fail at runtime). Is this a bug, or is there some reason for it?

void main() {
  var name = "Danny";
  print(name());
}

If I change var to String, then I get the warning I expect. But I thought the analyser inferred types (this seems like a very simple case)?


Lasse R.H. Nielsen

unread,
May 5, 2015, 4:21:47 AM5/5/15
to mi...@dartlang.org
Seems the analyzer doesn't recognize the call the same way it would recognize it if you wrote "name.x()". The latter does give a hint, but "name()" should as well (it's equivalent to "name.call()", which does cause a hint).

The analyzer has some issues with calls, I don't know if this is related: http://dartbug.com/12733

/L


--
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+uns...@dartlang.org.



--
Lasse R.H. Nielsen - l...@google.com  
'Faith without judgement merely degrades the spirit divine'
Google Denmark ApS - Frederiksborggade 20B, 1 sal - 1360 København K - Denmark - CVR nr. 28 86 69 84

Danny Tuppeny

unread,
May 5, 2015, 4:26:41 AM5/5/15
to mi...@dartlang.org
Ok, I'll re-post to the analyser list for discussion there; wasn't sure if I was overlooking something. Ta!

Paul Berry

unread,
May 5, 2015, 8:38:43 AM5/5/15
to mi...@dartlang.org
In case anyone is curious and doesn't follow the analyzer list, I've filed a bug for this: https://code.google.com/p/dart/issues/detail?id=23384
Reply all
Reply to author
Forward
0 new messages