Deep Learning Type Inference

被引:122
作者
Hellendoorn, Vincent J. [1 ]
Bird, Christian [2 ]
Barr, Earl T. [3 ]
Allamanis, Miltiadis [4 ]
机构
[1] Univ Calif Davis, Davis, CA 95616 USA
[2] Microsoft Res, Redmond, WA USA
[3] UCL, London, England
[4] Microsoft Res Cambridge, Cambridge, England
来源
ESEC/FSE'18: PROCEEDINGS OF THE 2018 26TH ACM JOINT MEETING ON EUROPEAN SOFTWARE ENGINEERING CONFERENCE AND SYMPOSIUM ON THE FOUNDATIONS OF SOFTWARE ENGINEERING | 2018年
基金
英国工程与自然科学研究理事会; 美国国家科学基金会;
关键词
Type Inference; Deep Learning; Naturalness;
D O I
10.1145/3236024.3236051
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Dynamically typed languages such as JavaScript and Python are increasingly popular, yet static typing has not been totally eclipsed: Python now supports type annotations and languages like Type-Script offer a middle-ground for JavaScript: a strict superset of JavaScript, to which it transpiles, coupled with a type system that permits partially typed programs. However, static typing has a cost: adding annotations, reading the added syntax, and wrestling with the type system to fix type errors. Type inference can ease the transition to more statically typed code and unlock the benefits of richer compile-time information, but is limited in languages like JavaScript as it cannot soundly handle duck-typing or runtime evaluation via eval. We propose DEEPTYPER, a deep learning model that understands which types naturally occur in certain contexts and relations and can provide type suggestions, which can often be verified by the type checker, even if it could not infer the type initially. DEEPTYPER, leverages an automatically aligned corpus of tokens and types to accurately predict thousands of variable and function type annotations. Furthermore, we demonstrate that context is key in accurately assigning these types and introduce a technique to reduce overfitting on local cues while highlighting the need for further improvements. Finally, we show that our model can interact with a compiler to provide more than 4,000 additional type annotations with over 95% precision that could not be inferred without the aid of DEEPTYPER.
引用
收藏
页码:152 / 162
页数:11
相关论文
共 29 条
[1]   Types for safe locking: Static race detection for Java']Java [J].
Abadi, M ;
Flanagan, C ;
Freund, SN .
ACM TRANSACTIONS ON PROGRAMMING LANGUAGES AND SYSTEMS, 2006, 28 (02) :207-255
[2]   Learning Natural Coding Conventions [J].
Allamanis, Miltiadis ;
Barr, Earl T. ;
Bird, Christian ;
Sutton, Charles .
22ND ACM SIGSOFT INTERNATIONAL SYMPOSIUM ON THE FOUNDATIONS OF SOFTWARE ENGINEERING (FSE 2014), 2014, :281-293
[3]  
Andreasen E, 2014, ACM SIGPLAN NOTICES, V49, P17, DOI [10.1145/2660193.2660214, 10.1145/2714064.2660214]
[4]  
[Anonymous], 2014, ICLR 2015
[5]  
[Anonymous], LIPICS LEIBNIZ INT P
[6]  
[Anonymous], 2016, Distill, DOI DOI 10.23915/DISTILL.00001
[7]  
[Anonymous], 2017, P 39 INT C SOFTW ENG
[8]  
[Anonymous], 2017, ARXIV170505487
[9]  
[Anonymous], 2017, ARXIV170406611
[10]  
[Anonymous], 2015, ARXIV