dart-atom / dart

A Dart plugin for Atom.
http://dart-atom.github.io/dart/
BSD 3-Clause "New" or "Revised" License
154 stars 44 forks source link

Null coalescing operator: type mismatch #1065

Open gchumillas opened 8 years ago

gchumillas commented 8 years ago

The following code does not cause any warning:

String test = 100 ?? 'another string';

I think that the plugin should be alerted and print the following error:

[error] A value of type 'int' cannot be assigned to a variable of type 'String'
devoncarew commented 8 years ago

Does it if you have explicit types? int myInt = 100; String myString = 'another string'; ...

And just FYI, issues like this are probably better filed against dart-lang/sdk.

gchumillas commented 8 years ago

No, it still doesn't throw any warning:

int myInt = 100;
String myString = 'another string';
String test = myInt ?? myString; // no warnings, no errors, no anything

I'll publish this issue in the dart-lang/sdk repository.