LambdaNet: Probabilistic Type Inference using Graph Neural Networks
arXiv:2005.02161
Abstract
As gradual typing becomes increasingly popular in languages like Python and TypeScript, there is a growing need to infer type annotations automatically. While type annotations help with tasks like code completion and static error catching, these annotations cannot be fully determined by compilers and are tedious to annotate by hand. This paper proposes a probabilistic type inference scheme for TypeScript based on a graph neural network. Our approach first uses lightweight source code analysis to generate a program abstraction called a type dependency graph, which links type variables with logical constraints as well as name and usage information. Given this program abstraction, we then use a graph neural network to propagate information between related type variables and eventually make type predictions. Our neural architecture can predict both standard types, like number or string, as well as user-defined types that have not been encountered during training. Our experimental results show that our approach outperforms prior work in this space by (absolute) on library types, while having the ability to make type predictions that are out of scope for existing techniques.
Accepted as a poster at ICLR 2020
References in corpus (3)
Cited by in corpus (16)
- Graph Neural Networks: Taxonomy, Advances and Trends
- Contrastive Code Representation Learning
- Static Inference Meets Deep Learning: A Hybrid Type Inference Approach for Python
- Self-Supervised Bug Detection and Repair
- Adversarial Robustness for Code
- Program Synthesis with Large Language Models
- Unified Abstract Syntax Tree Representation Learning for Cross-Language Program Classification
- Augmenting Decompiler Output with Learned Variable Names and Types
- Learning to Execute Programs with Instruction Pointer Attention Graph Neural Networks
- Learning to Represent Programs with Heterogeneous Graphs
- OptTyper: Probabilistic Type Inference by Optimising Logical and Natural Constraints
- MISIM: A Neural Code Semantics Similarity System Using the Context-Aware Semantics Structure
- Learning Semantic Program Embeddings with Graph Interval Neural Network
- Advanced Graph-Based Deep Learning for Probabilistic Type Inference
- Cross-Domain Evaluation of a Deep Learning-Based Type Inference System
- Scaling Up Graph Neural Networks Via Graph Coarsening