一句话:提出两阶段方法 Stir,用神经网络预测 token 类型标签并还原复杂类型,将类型推断转化为序列到图解析问题。
论文关注不完整程序的类型推断问题:这类程序可能语法不完整,整体程序的语法分析往往失败,现有方法难以处理。作者提出两阶段方法 Stir。第一阶段用神经网络为每个 token 预测类型标签,从而推断程序中的所有简单类型;第二阶段对预测为复杂类型的 token 进一步细化,利用类型图表示复杂类型。与以往把类型推断视为分类问题的机器学习方法不同,Stir 将其归结为序列到图的解析问题(sequence-to-graph parsing)。实验表明,Stir 在简单类型上达到 97.37% 的准确率;将复杂类型表示为有向图(类型图)后,在复杂类型和零样本复杂类型上分别取得 77.36% 和 59.61% 的类型相似度得分。
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.
@inproceedings{PengXYGLXY23,
title = {Statistical Type Inference for Incomplete Programs},
author = {Yaohui Peng and Jing Xie and Qiongling Yang and Hanwen Guo and Qingan Li and Jingling Xue and Mengting Yuan},
booktitle = {FSE},
year = {2023},
doi = {10.1145/3611643.3616283}
}