Closed efortuna closed 5 years ago
cc @brianegan
This looks similar to https://github.com/dart-lang/sdk/issues/36055.
Are you sure that running the analyzer from the command line is using the same analysis_options.yaml
? My guess is that somehow you're using strong-mode: implicit-casts: false
with VS Code but not with your other cases.
I just tried it with dartanalyzer 2.2.1 and could reproduce it from the command-line with strong-mode: implicit-casts: false
. FWIW, dartanalyzer 2.1.0 does not complain.
Yeah, I can repro with implicit-casts
disabled. I agree with @jamesderlin that is seems like a different in analysis_options
or a different SDK version (which could be explained by the IDEs finding the SDK differently). The analysis_options file used is picked up by the analyzer, so I wouldn't expect that to differ - but if you copy/pasted the code into a different file when testing between IDEs, I guess that it could be that.
If you run the Dart: Open Analyzer Diagnostics command in VS Code, it'll open the diagnostics for the server which will include the versions on the Status page, and info about the analysis roots and options on the Contexts page:
I've kept implicit casts disabled for now in our codebase and changed the line to double b = -1 * a[0];
, which seems to fix it for me. Not the best, but works for now without disabling the analyzer check
Okey - @efortuna does it seem reasonable to you to close this as a dupe of https://github.com/dart-lang/sdk/issues/36055? Or do you want to do some more digging to get to the bottom of why you saw differences across IDEs?
will close as a dupe
Consider the following valid Dart code:
Produces the following error in VS Code: "code": "invalid_assignment", "severity": 8, "message": "A value of type 'dynamic' can't be assigned to a variable of type 'double'.\nTry changing the type of the variable, or casting the right-hand type to 'double'."
This does not happen if I run dartanalyzer from the command line (dartanalyzer version 2.2.1-edge.1490a90bc1c4cbbf13470af3408584e57d135fb2) OR run in Android Studio. I see this in both the 2.25 extension and the 2.26 one Danny just shared with me.