Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article

Finding minimum type error sources

Published: 15 October 2014 Publication History

Abstract

Automatic type inference is a popular feature of functional programming languages. If a program cannot be typed, the compiler typically reports a single program location in its error message. This location is the point where the type inference failed, but not necessarily the actual source of the error. Other potential error sources are not even considered. Hence, the compiler often misses the true error source, which increases debugging time for the programmer. In this paper, we present a general framework for automatic localization of type errors. Our algorithm finds all minimum error sources, where the exact definition of minimum is given in terms of a compiler-specific ranking criterion. Compilers can use minimum error sources to produce more meaningful error reports, and for automatic error correction. Our approach works by reducing the search for minimum error sources to an optimization problem that we formulate in terms of weighted maximum satisfiability modulo theories (MaxSMT). The reduction to weighted MaxSMT allows us to build on SMT solvers to support rich type systems and at the same time abstract from the concrete criterion that is used for ranking the error sources. We have implemented an instance of our framework targeted at Hindley-Milner type systems and evaluated it on existing OCaml benchmarks for type error localization. Our evaluation shows that our approach has the potential to significantly improve the quality of type error reports produced by state of the art compilers.

References

[1]
A. Aiken and E. L. Wimmers. Type inclusion constraints and type inference. In FPCA, pages 31--41. ACM, 1993.
[2]
C. Barrett, C. L. Conway, M. Deters, L. Hadarean, D. Jovanović, T. King, A. Reynolds, and C. Tinelli. CVC4. In CAV, pages 171--177. Springer-Verlag, 2011.
[3]
C. Barrett, R. Sebastiani, S. A. Seshia, and C. Tinelli. Satisfiability Modulo Theories, chapter 26, pages 825--885. Volume 185 of Biere et al. {6}, February 2009.
[4]
C. Barrett, I. Shikanian, and C. Tinelli. An abstract decision procedure for a theory of inductive data types. Journal on Satisfiability, Boolean Modeling and Computation, 3:21--46, 2007.
[5]
C. Barrett, A. Stump, and C. Tinelli. The SMT-LIB standard - version 2.0. In SMT, 2010.
[6]
A. Biere, M. J. H. Heule, H. van Maaren, and T. Walsh, editors. Handbook of Satisfiability, volume 185 of Frontiers in Artificial Intelligence and Applications. IOS Press, February 2009.
[7]
S. Chen and M. Erwig. Counter-factual typing for debugging type errors. In POPL, pages 583--594. ACM, 2014.
[8]
O. Chitil. Compositional explanation of types and algorithmic debugging of type errors. In ICFP, ICFP '01, pages 193--204. ACM, 2001.
[9]
A. Cimatti, A. Griggio, B. J. Schaafsma, and R. Sebastiani. A Modular Approach to MaxSAT Modulo Theories. In SAT, pages 150--165, 2013.
[10]
V. Cremet, F. Garillot, S. Lenglet, and M. Odersky. A Core Calculus for Scala Type Checking. In MFCS, volume 4162 of LNCS, pages 1--23. Springer, 2006.
[11]
L. De Moura and N. Bjørner. Z3: An Efficient SMT Solver. In TACAS, pages 337--340. Springer-Verlag, 2008.
[12]
D. Duggan and F. Bent. Explaining type inference. In Science of Computer Programming, pages 37--83, 1995.
[13]
B. Dutertre and L. de Moura. The Yices SMT solver. Technical report, SRI International, 2006.
[14]
EasyOCaml. http://easyocaml.forge.ocamlcore.org. {Online; accessed 10-March-2014}.
[15]
H. Gast. Explaining ML type errors by data flows. In Implementation and Application of Functional Languages, pages 72--89. Springer, 2005.
[16]
T. Gvero, V. Kuncak, I. Kuraj, and R. Piskac. Complete completion using types and weights. In PLDI, pages 27--38. ACM, 2013.
[17]
C. Haack and J. B. Wells. Type error slicing in implicitly typed higher-order languages. Sci. Comput. Program., pages 189--224, 2004.
[18]
The Haskell Programming Language. http://www.haskell.org/. {Online; accessed 15-March-2014}.
[19]
J. R. Hindley. The principal type-scheme of an object in combinatory logic. Transactions of the American Mathematical Society, 146:2960, 1969.
[20]
M. Jose and R. Majumdar. Bug-Assist: Assisting Fault Localization in ANSI-C Programs. In CAV, pages 504--509. Springer-Verlag, 2011.
[21]
U. Junker. Quickxplain: Preferred explanations and relaxations for over-constrained problems. In AAAI, pages 167--172, 2004.
[22]
A. J. Kfoury, J. Tiuryn, and P. Urzyczyn. ML Typability is DEXTIME-Complete. In CAAP, pages 206--220, 1990.
[23]
D. Le Berre, A. Parrain, et al. The sat4j library, release 2.2, system description. Journal on Satisfiability, Boolean Modeling and Computation, 7:59--64, 2010.
[24]
B. Lerner, M. Flower, D. Grossman, and C. Chambers. Searching for type-error messages. In PLDI. ACM Press, 2007.
[25]
X. Leroy, D. Doligez, A. Frisch, J. Garrigue, D. Rémy, and J. Vouillon. OCaml Manual: Module Pervasives. http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html. {Online; accessed 14-March-2014}.
[26]
C. M. Li and F. Manyà. MaxSAT, Hard and Soft Constraints, chapter 19, pages 613--631. Volume 185 of Biere et al. {6}, February 2009.
[27]
H. G. Mairson. Deciding ML Typability is Complete for Deterministic Exponential Time. In POPL, pages 382--401, 1990.
[28]
J. Marques-Sila and J. Planes. Algorithms for maximum satisfiability using unsatisfiable cores. In K. Gulati, editor, Advanced Techniques in Logic Synthesis, Optimizations and Applications, pages 171--182. Springer New York, 2011.
[29]
R. Milner. A theory of type polymorphism in programming. J. Comput. Syst. Sci., 17(3):348--375, 1978.
[30]
M. Neubauer and P. Thiemann. Discriminative sum types locate the source of type errors. In ICFP, pages 15--26. ACM Press, 2003.
[31]
OCaml. http://ocaml.org. {Online; accessed 2-February-2014}.
[32]
M. Odersky, M. Sulzmann, and M.Wehr. Type inference with constrained types. TAPOS, 5(1):35--55, 1999.
[33]
J. A. Robinson. Computational logic: The unification computation. Machine intelligence, 6(63--72):10--1, 1971.
[34]
P. M. Rondon, M. Kawaguci, and R. Jhala. Liquid types. In PLDI, pages 159--169. ACM, 2008.
[35]
T. Schrijvers, S. L. P. Jones, M. Sulzmann, and D. Vytiniotis. Complete and decidable type inference for gadts. In ICFP, pages 341--352. ACM, 2009.
[36]
P. J. Stuckey, M. Sulzmann, and J. Wazny. Interactive type debugging in haskell. In Haskell, pages 72--83. ACM, 2003.
[37]
P. J. Stuckey, M. Sulzmann, and J. Wazny. Improving type error diagnosis. In ACM SIGPLAN Workshop on Haskell, pages 80--91. ACM, 2004.
[38]
M. Sulzmann, M. Müller, and C. Zenger. Hindley/Milner style type systems in constraint form. Res. Rep. ACRC-99-009, University of South Australia, School of Computer and Information Science. July, 1999.
[39]
F. Tip and T. B. Dinesh. A slicing-based approach for locating type errors. ACM Trans. Softw. Eng. Methodol., pages 5--55, 2001.
[40]
D. Vytiniotis, S. L. P. Jones, T. Schrijvers, and M. Sulzmann. Outsidein(x) modular type inference with local assumptions. J. Funct. Program., 21(4-5):333--412, 2011.
[41]
M. Wand. Finding the source of type errors. In POPL, pages 38--43. ACM, 1986.
[42]
D. Zhang and A. C. Myers. Toward general diagnosis of static errors. In POPL, pages 569--581. ACM, 2014.

Cited By

View all
  • (2018)Automatic diagnosis and correction of logical errors for functional programming assignmentsProceedings of the ACM on Programming Languages10.1145/32765282:OOPSLA(1-30)Online publication date: 24-Oct-2018
  • (2017)Learning user friendly type-error messagesProceedings of the ACM on Programming Languages10.1145/31339301:OOPSLA(1-29)Online publication date: 12-Oct-2017
  • (2017)How type errors were fixed and what students did?Proceedings of the ACM on Programming Languages10.1145/31339291:OOPSLA(1-27)Online publication date: 12-Oct-2017
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM SIGPLAN Notices
ACM SIGPLAN Notices  Volume 49, Issue 10
OOPSLA '14
October 2014
907 pages
ISSN:0362-1340
EISSN:1558-1160
DOI:10.1145/2714064
  • Editor:
  • Andy Gill
Issue’s Table of Contents
  • cover image ACM Conferences
    OOPSLA '14: Proceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages & Applications
    October 2014
    946 pages
    ISBN:9781450325851
    DOI:10.1145/2660193
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 15 October 2014
Published in SIGPLAN Volume 49, Issue 10

Check for updates

Author Tags

  1. diagnostics
  2. satisfiability modulo theories
  3. type errors

Qualifiers

  • Research-article

Funding Sources

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)12
  • Downloads (Last 6 weeks)1
Reflects downloads up to 27 Jan 2025

Other Metrics

Citations

Cited By

View all
  • (2018)Automatic diagnosis and correction of logical errors for functional programming assignmentsProceedings of the ACM on Programming Languages10.1145/32765282:OOPSLA(1-30)Online publication date: 24-Oct-2018
  • (2017)Learning user friendly type-error messagesProceedings of the ACM on Programming Languages10.1145/31339301:OOPSLA(1-29)Online publication date: 12-Oct-2017
  • (2017)How type errors were fixed and what students did?Proceedings of the ACM on Programming Languages10.1145/31339291:OOPSLA(1-27)Online publication date: 12-Oct-2017
  • (2015)TypeDevil: Dynamic Type Inconsistency Analysis for JavaScript2015 IEEE/ACM 37th IEEE International Conference on Software Engineering10.1109/ICSE.2015.51(314-324)Online publication date: May-2015
  • (2015)A Type-Directed Approach to Program RepairComputer Aided Verification10.1007/978-3-319-21690-4_35(511-517)Online publication date: 16-Jul-2015
  • (2024)Total Type Error Localization and Recovery with HolesProceedings of the ACM on Programming Languages10.1145/36329108:POPL(2041-2068)Online publication date: 5-Jan-2024
  • (2023)Practical Inference of Nullability TypesProceedings of the 31st ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering10.1145/3611643.3616326(1395-1406)Online publication date: 30-Nov-2023
  • (2023)How to Evaluate Blame for Gradual Types, Part 2Proceedings of the ACM on Programming Languages10.1145/36078367:ICFP(159-186)Online publication date: 31-Aug-2023
  • (2023)Pluggable Type Inference for Free2023 38th IEEE/ACM International Conference on Automated Software Engineering (ASE)10.1109/ASE56229.2023.00186(1542-1554)Online publication date: 11-Sep-2023
  • (2023)Error Localization for Sequential Effect SystemsStatic Analysis10.1007/978-3-031-44245-2_16(343-370)Online publication date: 24-Oct-2023
  • Show More Cited By

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media