Abstract
Optional typing is traditionally viewed as a compromise between static and dynamic type checking, where code without type annotations is not checked until runtime. We demonstrate that optional type annotations in Dart programs can be integrated into a flow analysis to provide static type safety guarantees both for annotated and non-annotated parts of the code. We explore two approaches: one that uses type annotations for filtering, and one that uses them as specifications. What makes this particularly challenging for Dart is that its type system is unsound even for fully annotated code. Experimental results show that the technique is remarkably effective, even without context sensitivity: 99.3% of all property lookup operations are reported type safe in a collection of benchmark programs.
- O. Agesen. The cartesian product algorithm: Simple and precise type inference of parametric polymorphism. In Object-Oriented Programming, 9th European Conference (ECOOP), 1995. Google Scholar
Digital Library
- G. Bracha and D. Ungar. Mirrors: design principles for meta-level facilities of object-oriented programming languages. In Proc. ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), 2004. Google Scholar
Digital Library
- E. Brandt. Why Dart types are optional and unsound, 2011. https: //www.dartlang.org/articles/why-dart-types/.Google Scholar
- R. Cartwright and M. Fagan. Soft typing. In Proc. ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), 1991. Google Scholar
Digital Library
- D. R. Chase, M. Wegman, and F. K. Zadeck. Analysis of pointers and structures. In Proc. ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), 1990. Google Scholar
Digital Library
- J. Dean, D. Grove, and C. Chambers. Optimization of object-oriented programs using static class hierarchy analysis. In Proc. Object-Oriented Programming, 9th European Conference (ECOOP), 1995. Google Scholar
Digital Library
- Ecma International. Dart Programming Language Specification, ECMA-408, 4th Edition, December 2015.Google Scholar
- E. Ernst, A. Møller, M. Schwarz, and F. Strocco. Message safety in Dart. Science of Computer Programming, 2016. In press. Earlier version in Proc. 11th Dynamic Languages Symposium (DLS), 2015. Google Scholar
Digital Library
- Facebook Inc. Flow – a static type checker for JavaScript, 2016. http://flowtype.org/.Google Scholar
- C. Flanagan, M. Flatt, S. Krishnamurthi, S. Weirich, and M. Felleisen. Catching bugs in the web of program invariants. In Proc. ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), 1996. Google Scholar
Digital Library
- Google Inc. Strong mode, 2015. https://github.com/dart-lang/ dev_compiler/blob/master/STRONG_MODE.md.Google Scholar
- Google Inc. dart2js, 2016. https://www.dartlang.org/tools/ dart2js/.Google Scholar
- Google Inc. dartanalyzer, 2016. https://github.com/dart-lang/ analyzer_cli.Google Scholar
- R. Hasti and S. Horwitz. Using static single assignment form to improve flow-insensitive pointer analysis. In Proc. ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), 1998. Google Scholar
Digital Library
- N. Heintze. Set-based analysis of ML programs. In LISP and Functional Programming, pages 306–317, 1994. Google Scholar
Digital Library
- S. H. Jensen, A. Møller, and P. Thiemann. Type analysis for JavaScript. In Proc. 16th International Static Analysis Symposium (SAS), 2009. Google Scholar
Digital Library
- H. Mehnert. Extending Dylan’s type system for better type inference and error detection. In International Lisp Conference (ILC), 2010. Google Scholar
Digital Library
- F. Ortin. Type inference to optimize a hybrid statically and dynamically typed language. Comput. J., 54(11):1901–1924, 2011. Google Scholar
Digital Library
- J. Palsberg and M. I. Schwartzbach. Safety analysis versus type inference. Inf. Comput., 118(1), 1995. Google Scholar
Digital Library
- A. Rastogi, A. Chaudhuri, and B. Hosmer. The ins and outs of gradual type inference. In Proc. 39th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), 2012. Google Scholar
Digital Library
- J. G. Siek and W. Taha. Gradual typing for functional languages. In Scheme and Functional Programming Workshop, 2006.Google Scholar
- J. G. Siek and M. Vachharajani. Gradual typing with unification-based inference. In Proc. Symposium on Dynamic Languages (DLS), 2008. Google Scholar
Digital Library
- J. G. Siek, P. Thiemann, and P. Wadler. Blame and coercion: together again for the first time. In Proc. 36th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), 2015. Google Scholar
Digital Library
- J. G. Siek, M. M. Vitousek, M. Cimini, and J. T. Boyland. Refined criteria for gradual typing. In Proc. 1st Summit on Advances in Programming Languages (SNAPL), 2015.Google Scholar
- M. Sridharan, S. Chandra, J. Dolby, S. J. Fink, and E. Yahav. Alias analysis for object-oriented programs. In Aliasing in Object-Oriented Programming. Types, Analysis and Verification, volume 7850 of LNCS, pages 196–232. Springer, 2013. Google Scholar
Digital Library
- A. Takikawa, D. Feltey, B. Greenman, M. S. New, J. Vitek, and M. Felleisen. Is sound gradual typing dead? In Proc. 43rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), 2016. Google Scholar
Digital Library
- The Mypy Project. mypy – optional static typing for Python, 2016. https://mypy-lang.org/.Google Scholar
Index Terms
Type safety analysis for Dart
Recommendations
Message safety in Dart
DLS 2015: Proceedings of the 11th Symposium on Dynamic LanguagesUnlike traditional static type checking, the type system in the Dart programming language is unsound by design, even for fully annotated programs. The rationale has been that this allows compile-time detection of likely errors and enables code ...
Type safety analysis for Dart
DLS 2016: Proceedings of the 12th Symposium on Dynamic LanguagesOptional typing is traditionally viewed as a compromise between static and dynamic type checking, where code without type annotations is not checked until runtime. We demonstrate that optional type annotations in Dart programs can be integrated into a ...
Message safety in Dart
DLS '15Unlike traditional static type checking, the type system in the Dart programming language is unsound by design, even for fully annotated programs. The rationale has been that this allows compile-time detection of likely errors and enables code ...







Comments