Skip to main content
QUICK REVIEW

[Paper Review] Learning to Blame: Localizing Novice Type Errors with Data-Driven Diagnosis

Eric L. Seidel, Huma Sibghat|arXiv (Cornell University)|Aug 25, 2017
Software Engineering ResearchComputer Science20 references3 citations
TL;DR

This paper introduces Nate, a data-driven approach that uses supervised machine learning on a corpus of 5,000 novice OCaml programs to localize type errors by predicting the most likely sub-expression responsible for a type error. By leveraging syntactic, typing, and structural features—including parent and child expression context—Nate achieves 72% precision on the top-ranked blame assignment, outperforming OCaml and SHErrLoc by 28 and 16 percentage points, respectively.

ABSTRACT

Localizing type errors is challenging in languages with global type inference, as the type checker must make assumptions about what the programmer intended to do. We introduce Nate, a data-driven approach to error localization based on supervised learning. Nate analyzes a large corpus of training data -- pairs of ill-typed programs and their "fixed" versions -- to automatically learn a model of where the error is most likely to be found. Given a new ill-typed program, Nate executes the model to generate a list of potential blame assignments ranked by likelihood. We evaluate Nate by comparing its precision to the state of the art on a set of over 5,000 ill-typed OCaml programs drawn from two instances of an introductory programming course. We show that when the top-ranked blame assignment is considered, Nate's data-driven model is able to correctly predict the exact sub-expression that should be changed 72% of the time, 28 points higher than OCaml and 16 points higher than the state-of-the-art SHErrLoc tool. Furthermore, Nate's accuracy surpasses 85% when we consider the top two locations and reaches 91% if we consider the top three.

Motivation & Objective

  • Address the challenge of localizing type errors in languages with global type inference, where error messages often point far from the true source of the error.
  • Overcome the limitations of constraint-based error localization methods, which are not extensible or adaptable to real-world novice programming mistakes.
  • Develop a scalable, data-driven approach to error localization that learns from actual novice programmer behavior rather than expert assumptions.
  • Create a large, realistic dataset of ill-typed programs and their fixes to train and evaluate a machine learning model for error localization.
  • Demonstrate that learned models can generalize across different cohorts of novice programmers and outperform purely symbolic or heuristic-based methods.

Proposed method

  • Collect a corpus of 5,000 ill-typed OCaml programs and their subsequent fixes by instrumenting the OCaml compiler to log student program submissions over two semesters.
  • Extract labeled training data by computing tree-diffs between ill-typed and corrected programs to identify the exact sub-expression that was changed.
  • Engineer a rich set of features per program expression, including syntactic structure, type information, and contextual features from parent and child expressions.
  • Train a supervised machine learning model (e.g., gradient-boosted trees) to predict the likelihood of each expression being the source of a type error.
  • Rank potential blame assignments by model confidence and evaluate precision at top-1, top-2, and top-3 ranks.
  • Evaluate generalization by training on one academic year’s data and testing on another, demonstrating robustness to data distribution shifts.

Experimental results

Research questions

  • RQ1Can a data-driven model trained on real novice programming behavior outperform constraint-based error localization techniques in identifying the true source of type errors?
  • RQ2How effective is the inclusion of contextual features (parent and child expressions) in improving error localization precision compared to isolated expression features?
  • RQ3To what extent can a model trained on one cohort of novice programmers generalize to another cohort from a different academic term?
  • RQ4Does a data-driven approach that learns from actual fixes reduce the bias inherent in expert-designed heuristics for error localization?
  • RQ5Can a model trained on a single course’s data achieve high precision without requiring extensive, manually labeled datasets?

Key findings

  • Nate achieves 72% precision in correctly identifying the exact sub-expression that should be changed when considering only the top-ranked blame assignment, outperforming OCaml by 28 percentage points and SHErrLoc by 16 points.
  • When considering the top two blame locations, Nate’s precision reaches 85%, and with the top three, it reaches 91%, demonstrating strong recall across multiple candidates.
  • The model trained on one academic year’s data generalizes well to the other year’s programs, indicating robustness to data distribution shifts and practical usability across different student cohorts.
  • Adding contextual features—specifically, features from an expression’s parent and child expressions—leads to a 16-point improvement over state-of-the-art SHErrLoc, highlighting the importance of structural context.
  • While models based solely on isolated expression features underperform symbolic methods, the integration of type error slice features brings performance in line with the state of the art, and further context integration surpasses it.
  • The approach demonstrates that data-driven models trained on real novice error patterns can adapt to actual programming mistakes more effectively than expert-hardcoded heuristics, reducing bias in error localization.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.