skip to main content
research-article

Finding minimum type error sources

Published:15 October 2014Publication History
Skip Abstract Section

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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle Scholar
  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.Google ScholarGoogle ScholarCross RefCross Ref
  5. C. Barrett, A. Stump, and C. Tinelli. The SMT-LIB standard - version 2.0. In SMT, 2010.Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. S. Chen and M. Erwig. Counter-factual typing for debugging type errors. In POPL, pages 583--594. ACM, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. O. Chitil. Compositional explanation of types and algorithmic debugging of type errors. In ICFP, ICFP '01, pages 193--204. ACM, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. A. Cimatti, A. Griggio, B. J. Schaafsma, and R. Sebastiani. A Modular Approach to MaxSAT Modulo Theories. In SAT, pages 150--165, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. L. De Moura and N. Bjørner. Z3: An Efficient SMT Solver. In TACAS, pages 337--340. Springer-Verlag, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. D. Duggan and F. Bent. Explaining type inference. In Science of Computer Programming, pages 37--83, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. B. Dutertre and L. de Moura. The Yices SMT solver. Technical report, SRI International, 2006.Google ScholarGoogle Scholar
  14. EasyOCaml. http://easyocaml.forge.ocamlcore.org. {Online; accessed 10-March-2014}.Google ScholarGoogle Scholar
  15. H. Gast. Explaining ML type errors by data flows. In Implementation and Application of Functional Languages, pages 72--89. Springer, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. T. Gvero, V. Kuncak, I. Kuraj, and R. Piskac. Complete completion using types and weights. In PLDI, pages 27--38. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. C. Haack and J. B. Wells. Type error slicing in implicitly typed higher-order languages. Sci. Comput. Program., pages 189--224, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. The Haskell Programming Language. http://www.haskell.org/. {Online; accessed 15-March-2014}.Google ScholarGoogle Scholar
  19. J. R. Hindley. The principal type-scheme of an object in combinatory logic. Transactions of the American Mathematical Society, 146:2960, 1969.Google ScholarGoogle Scholar
  20. M. Jose and R. Majumdar. Bug-Assist: Assisting Fault Localization in ANSI-C Programs. In CAV, pages 504--509. Springer-Verlag, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. U. Junker. Quickxplain: Preferred explanations and relaxations for over-constrained problems. In AAAI, pages 167--172, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. A. J. Kfoury, J. Tiuryn, and P. Urzyczyn. ML Typability is DEXTIME-Complete. In CAAP, pages 206--220, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle ScholarCross RefCross Ref
  24. B. Lerner, M. Flower, D. Grossman, and C. Chambers. Searching for type-error messages. In PLDI. ACM Press, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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}.Google ScholarGoogle Scholar
  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.Google ScholarGoogle Scholar
  27. H. G. Mairson. Deciding ML Typability is Complete for Deterministic Exponential Time. In POPL, pages 382--401, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle ScholarCross RefCross Ref
  29. R. Milner. A theory of type polymorphism in programming. J. Comput. Syst. Sci., 17(3):348--375, 1978.Google ScholarGoogle ScholarCross RefCross Ref
  30. M. Neubauer and P. Thiemann. Discriminative sum types locate the source of type errors. In ICFP, pages 15--26. ACM Press, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. OCaml. http://ocaml.org. {Online; accessed 2-February-2014}.Google ScholarGoogle Scholar
  32. M. Odersky, M. Sulzmann, and M.Wehr. Type inference with constrained types. TAPOS, 5(1):35--55, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. J. A. Robinson. Computational logic: The unification computation. Machine intelligence, 6(63--72):10--1, 1971.Google ScholarGoogle Scholar
  34. P. M. Rondon, M. Kawaguci, and R. Jhala. Liquid types. In PLDI, pages 159--169. ACM, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. P. J. Stuckey, M. Sulzmann, and J. Wazny. Interactive type debugging in haskell. In Haskell, pages 72--83. ACM, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. P. J. Stuckey, M. Sulzmann, and J. Wazny. Improving type error diagnosis. In ACM SIGPLAN Workshop on Haskell, pages 80--91. ACM, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle Scholar
  39. F. Tip and T. B. Dinesh. A slicing-based approach for locating type errors. ACM Trans. Softw. Eng. Methodol., pages 5--55, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. M. Wand. Finding the source of type errors. In POPL, pages 38--43. ACM, 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. D. Zhang and A. C. Myers. Toward general diagnosis of static errors. In POPL, pages 569--581. ACM, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Finding minimum type error sources

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        • 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

          Copyright © 2014 ACM

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 15 October 2014

          Check for updates

          Qualifiers

          • research-article

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!