SimTyper: Sound Type Inference for Ruby using Type Equality PredictionVirtual
Thu 21 Oct 2021 19:20 - 19:35 at Zurich B - Dynamic Languages - mirror Chair(s): Julia Belyakova
Many researchers have explored type inference for dynamic languages. However, traditional type inference computes most general types which, for complex type systems—which are often needed to type dynamic languages—can be verbose, complex, and difficult to understand. In this paper, we introduce SimTyper, a Ruby type inference system that aims to infer \emph{usable} types—specifically, nominal and generic types—that match the types programmers write. SimTyper builds on InferDL, a recent Ruby type inference system that soundly combines standard type inference with heuristics. The key novelty of SimTyper is \emph{type equality prediction}, a new, machine learning-based technique that predicts when method arguments or returns are likely to have the same type. SimTyper finds pairs of positions that are predicted to have the same type yet one has a verbose, overly general solution and the other has a usable solution. It then guesses the two types are equal, keeping the guess if it is consistent with the rest of the program, and discarding it if not. In this way, types inferred by SimTyper are guaranteed to be sound. To perform type equality prediction, we introduce the \emph{deep similarity} (DeepSim) neural network. DeepSim is a novel machine learning classifier that follows the Siamese network architecture and uses CodeBERT, a pre-trained model, to embed source tokens into vectors that capture tokens and their contexts. DeepSim is trained on 100,000 pairs labeled with type similarity information extracted from 371 Ruby programs with manually documented, but not checked, types. We evaluated SimTyper on eight Ruby programs and found that, compared to standard type inference, SimTyper finds 69% more types that match programmer-written type information. Moreover, DeepSim can predict rare types that appear neither in the Ruby standard library nor in the training data. Our results show that type equality prediction can help type inference systems effectively produce more usable types.
Thu 21 OctDisplayed time zone: Central Time (US & Canada) change
10:50 - 12:10 | |||
10:50 15mTalk | Gradually Structured DataVirtual OOPSLA Stefan Malewski University of Chile, Michael Greenberg Stevens Institute of Technology, Éric Tanter University of Chile DOI Pre-print | ||
11:05 15mTalk | Solver-Based Gradual Type MigrationVirtual OOPSLA Luna Phipps-Costin University of Massachusetts at Amherst, Carolyn Jane Anderson Wellesley College, Michael Greenberg Stevens Institute of Technology, Arjun Guha Northeastern University DOI Pre-print | ||
11:20 15mTalk | SimTyper: Sound Type Inference for Ruby using Type Equality PredictionVirtual OOPSLA Milod Kazerounian University of Maryland at College Park, Jeffrey S. Foster Tufts University, Bonan Min Raytheon BBN Technologies DOI | ||
11:35 15mTalk | Promises Are Made to Be Broken: Migrating R to Strict SemanticsIn-Person OOPSLA Aviral Goel Northeastern University, Jan Ječmen Czech Technical University, Sebastián Krynski Czech Technical University, Olivier Flückiger Northeastern University, Jan Vitek Northeastern University; Czech Technical University DOI | ||
11:50 20mLive Q&A | Discussion, Questions and Answers OOPSLA |
18:50 - 20:10 | |||
18:50 15mTalk | Gradually Structured DataVirtual OOPSLA Stefan Malewski University of Chile, Michael Greenberg Stevens Institute of Technology, Éric Tanter University of Chile DOI Pre-print | ||
19:05 15mTalk | Solver-Based Gradual Type MigrationVirtual OOPSLA Luna Phipps-Costin University of Massachusetts at Amherst, Carolyn Jane Anderson Wellesley College, Michael Greenberg Stevens Institute of Technology, Arjun Guha Northeastern University DOI Pre-print | ||
19:20 15mTalk | SimTyper: Sound Type Inference for Ruby using Type Equality PredictionVirtual OOPSLA Milod Kazerounian University of Maryland at College Park, Jeffrey S. Foster Tufts University, Bonan Min Raytheon BBN Technologies DOI | ||
19:35 15mTalk | Promises Are Made to Be Broken: Migrating R to Strict SemanticsIn-Person OOPSLA Aviral Goel Northeastern University, Jan Ječmen Czech Technical University, Sebastián Krynski Czech Technical University, Olivier Flückiger Northeastern University, Jan Vitek Northeastern University; Czech Technical University DOI | ||
19:50 20mLive Q&A | Discussion, Questions and Answers OOPSLA |