3 ms·
Dart has dynamic typing. Code will not fail on compilation step and in runtime, if type mismatch expectations. You can try to get warnings (at least warnings) w
by EugeneOZ 12y ago
Dart has dynamic typing. Code will not fail on compilation step and in runtime, if type mismatch expectations. You can try to get warnings (at least warnings) with "checked" mode, but it works only with primitive cases, not with closures (no static analysis), so it's mostly useless and better to forget about it. It's only hinting for autocompletion in IDE (although autocompletion is a big thing). Even PHP 5 has strongest typing.
- skybrian 12y agoDart has static analysis as well. There is a server that reports errors and warnings in an IDE, and you can also run it as a batch job using the dartanalyzer command if you like. You can run dartanalyzer in a test, parse the output, and treat warnings as errors, and some people do. The question is whether the existing static analysis is enough. Some people think it isn't, and the Dart team has a couple of projects to improve on it. See the Dart Development Compiler [1] and linter [2]. The DDC project in particular plans to implement a subset of Dart that makes it easier to check types statically. This is all supposed to be integrated into the analysis engine using a plugin architecture so that these errors will show up in IDE's and anywhere else you want to display errors. It's work in progress, as are some of the other type checkers. [1] https://github.com/dart-lang/dev_compiler https://github.com/dart-lang/dev_compiler [2] https://github.com/dart-lang/linter https://github.com/dart-lang/linter
- EugeneOZ 12y agoI have quite opposite information from one of Dart authors, as response to my bug report: https://code.google.com/p/dart/issues/detail?id=23148 https://code.google.com/p/dart/issues/detail?id=23148 Sorry for offtopic, ruby devs :)
- skybrian 12y agoIt's confusing, but that's not a contradiction. The Dart spec defines the official set of errors and warnings and that particular snippet of code is within the spec, even though it's broken. The dartanalyzer tool follows the spec. But there are other possibilities. The dartanalyzer has hints which aren't part of the spec. Other tools (like the linter and DDC) can and will check for more problems. You could try refiling that as a feature request that the analyzer should provide a hint here, or perhaps try out DDC.