Statistical Type Inference for Incomplete Programs

被引:0
作者
Peng, Yaohui [1 ]
Xie, Jing [1 ]
Yang, Qiongling [1 ]
Guo, Hanwen [1 ]
Li, Qingan [1 ]
Xue, Jingling [2 ]
Yuan, Mengting [1 ]
机构
[1] Wuhan Univ, Sch Comp Sci, Wuhan, Peoples R China
[2] Univ New South Wales, Sch Comp Sci & Engn, Sydney, NSW, Australia
来源
PROCEEDINGS OF THE 31ST ACM JOINT MEETING EUROPEAN SOFTWARE ENGINEERING CONFERENCE AND SYMPOSIUM ON THE FOUNDATIONS OF SOFTWARE ENGINEERING, ESEC/FSE 2023 | 2023年
基金
中国国家自然科学基金;
关键词
Type inference; deep learning; structured learning; graph generation; FRAMEWORK;
D O I
10.1145/3611643.3616283
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
We propose a novel two-stage approach, Stir, for inferring types in incomplete programs that may be ill-formed, where whole-program syntactic analysis often fails. In the first stage, Stir predicts a type tag for each token by using neural networks, and consequently, infers all the simple types in the program. In the second stage, Stir refines the complex types for the tokens with predicted complex type tags. Unlike existing machine-learning-based approaches, which solve type inference as a classification problem, Stir reduces it to a sequence-to-graph parsing problem. According to our experimental results, Stir achieves an accuracy of 97.37% for simple types. By representing complex types as directed graphs (type graphs), Stir achieves a type similarity score of 77.36% and 59.61 % for complex types and zero-shot complex types, respectively.
引用
收藏
页码:720 / 732
页数:13
相关论文
共 51 条
[1]   TYPILUS: Neural Type Hints [J].
Allamanis, Miltiadis ;
Barr, Earl T. ;
Ducousso, Soline ;
Gao, Zheng .
PROCEEDINGS OF THE 41ST ACM SIGPLAN CONFERENCE ON PROGRAMMING LANGUAGE DESIGN AND IMPLEMENTATION (PLDI '20), 2020, :91-105
[2]  
Bielik P, 2016, PR MACH LEARN RES, V48
[3]  
Boone C, 2019, Arxiv, DOI arXiv:1912.00680
[4]   A graph distance metric based on the maximal common subgraph [J].
Bunke, H ;
Shearer, K .
PATTERN RECOGNITION LETTERS, 1998, 19 (3-4) :255-259
[5]   ATTRIBUTED PROGRAMMED GRAPH-GRAMMARS AND THEIR APPLICATION TO SCHEMATIC DIAGRAM INTERPRETATION [J].
BUNKE, H .
IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, 1982, 4 (06) :574-582
[6]  
Chai YT, 2022, PROC INT CONF SOFTW, P487, DOI 10.1145/3510003.3510125
[7]   Fast and precise type checking for JavaScript [J].
Chaudhuri A. ;
Vekris P. ;
Goldman S. ;
Roch M. ;
Levi G. .
Proceedings of the ACM on Programming Languages, 2017, 1 (OOPSLA)
[8]  
Chomsky N., 1959, Information and Control, V2, P137, DOI [DOI 10.1016/S0019-9958(59)90362-6, 10.1016/S0019-9958]
[9]  
Collins M., 2013, Lecture Notes
[10]   Polymorphism, Subtyping, and Type Inference in MLsub [J].
Dolan, Stephen ;
Mycroft, Alan .
ACM SIGPLAN NOTICES, 2017, 52 (01) :60-72