HiTyper: A Hybrid Static Type Inference Framework with Neural Prediction

05/08/2021
by   Yun Peng, et al.
0

Type inference for dynamic programming languages is an important yet challenging task. By leveraging the natural language information of existing human annotations, deep neural networks outperform other traditional techniques and become the state-of-the-art (SOTA) in this task. However, they are facing some new challenges, such as fixed type set, type drift, type correctness, and composite type prediction. To mitigate the challenges, in this paper, we propose a hybrid type inference framework named HiTyper, which integrates static inference into deep learning (DL) models for more accurate type prediction. Specifically, HiTyper creates a new syntax graph for each program, called type graph, illustrating the type flow among all variables in the program. Based on the type graph, HiTyper statically infers the types of the variables with appropriate static constraints. HiTyper then adopts a SOTA DL model to predict the types of other variables that cannot be inferred statically, during which process a type correction algorithm is employed to validate and correct the types recommended by the DL model. Extensive experiments show that HiTyper outperforms the SOTA DL approach by 12.7 terms of top-1 F1-score. Moreover, HiTyper filters out 50.6 candidate types recommended by the SOTA DL model, indicating that HiTyper could improve the correctness of predicted types. Case studies also demonstrate the capability of HiTyper in alleviating the fixed type set issue, and in handling type drift and complicated types such as composite data types.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
04/29/2020

LambdaNet: Probabilistic Type Inference using Graph Neural Networks

As gradual typing becomes increasingly popular in languages like Python ...
research
09/13/2020

Advanced Graph-Based Deep Learning for Probabilistic Type Inference

Dynamically typed languages such as JavaScript and Python have emerged a...
research
06/27/2021

PYInfer: Deep Learning Semantic Type Inference for Python Variables

Python type inference is challenging in practice. Due to its dynamic pro...
research
04/01/2020

OptTyper: Probabilistic Type Inference by Optimising Logical and Natural Constraints

We present a new approach to the type inference problem for dynamic lang...
research
12/02/2019

DLTPy: Deep Learning Type Inference of Python Function Signatures using Natural Language Context

Due to the rise of machine learning, Python is an increasingly popular p...
research
02/01/2019

StaTIX - Statistical Type Inference on Linked Data

Large knowledge bases typically contain data adhering to various schemas...
research
08/14/2022

Generic Go to Go: Dictionary-Passing, Monomorphisation, and Hybrid

Go is a popular statically-typed industrial programming language. To aid...

Please sign up or login with your details

Forgot password? Click here to reset