Hostname: page-component-76fb5796d-5g6vh Total loading time: 0 Render date: 2024-04-25T12:35:42.177Z Has data issue: false hasContentIssue false

Systematic identification and communication of type errors*

Published online by Cambridge University Press:  25 January 2018

SHENG CHEN
Affiliation:
UL Lafayette (e-mail: chen@louisiana.edu)
MARTIN ERWIG
Affiliation:
Oregon State University (e-mail: erwig@oregonstate.edu)
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

When type inference fails, it is often difficult to pinpoint the cause of the type error among many potential candidates. Generating informative messages to remove the type error is another difficult task due to the limited availability of type information. Over the last three decades many approaches have been developed to help debug type errors. However, most of these methods suffer from one or more of the following problems: (1) Being incomplete, they miss the real cause. (2) They cover many potential causes without distinguishing them. (3) They provide little or no information for how to remove the type error. Any one of this problems can turn the type-error debugging process into a tedious and ineffective endeavor. To address this issue, we have developed a method named counter-factual typing, which (1) finds a comprehensive set of error causes in AST leaves, (2) computes an informative message on how to get rid of the type error for each error cause, and (3) ranks all messages and iteratively presents the message for the most likely error cause. The biggest technical challenge is the efficient generation of all error messages, which seems to be exponential in the size of the expression. We address this challenge by employing the idea of variational typing that systematically reuses computations for shared parts and generates all messages by typing the whole ill-typed expression only once. We have evaluated our approach over a large set of examples collected from previous publications in the literature. The evaluation result shows that our approach outperforms previous approaches and is computationally feasible.

Type
Articles
Copyright
Copyright © Cambridge University Press 2018 

Footnotes

*

This work is supported by the National Science Foundation under the grants IIS-1314384, CCF-1717300, and CCF-1750886. We thank the anonymous POPL and JFP reviewers, whose feedback has improved both the content and the presentation of the paper.

References

Beaven, M. & Stansifer, R. (1994) Explaining type errors in polymorphic languages. ACM Lett. Program. Lang. Syst. 2, 1730.Google Scholar
Bernstein, K. L. & Stark, E. W. (1995) Debugging Type Errors. Tech. rept. State University of New York at Stony Brook.Google Scholar
Braßel, B. (2004) Typehope: There is hope for your type errors. In Proceedings of International Workshop on Implementation of Functional Languages.Google Scholar
Chambers, C., Chen, S., Le, D. & Scaffidi, C. (2012) The function, and dysfunction, of information sources in learning functional programming. J. Comput. Sci. Colleges. 28 (1), 220226.Google Scholar
Chen, S. & Erwig, M. (2014a) Counter-factual typing for debugging type errors. In Proceedings of ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 583–594.Google Scholar
Chen, S. & Erwig, M. (2014b) Guided type debugging. In Proceedings of International Symposium on Functional and Logic Programming, LNCS, vol. 8475, pp. 35–51.Google Scholar
Chen, S., Erwig, M. & Walkingshaw, E. (2012) An error-tolerant type system for variational lambda calculus. In Proceedings of ACM International Conference on Functional Programming, pp. 29–40.Google Scholar
Chen, S., Erwig, M. & Walkingshaw, E. (2014) Extending type inference to variational programs. ACM Trans. Program. Lang. Syst. 36 (1), 1:11:54.Google Scholar
Chen, S., Erwig, M. & Smeltzer, K. (2017) Exploiting diversity in type checkers for better error messages. J. Vis. Lang. Comput. 39 (C), 1021.Google Scholar
Chitil, O. (2001 September) Compositional explanation of types and algorithmic debugging of type errors. In Proceedings of ACM International Conference on Functional Programming, pp. 193–204.Google Scholar
Choppella, V. (2002) Unification Source-Tracking with Application to Diagnosis of Type Inference. Ph.D. thesis, Indiana University.Google Scholar
Damas, L. & Milner, R. (1982) Principal type-schemes for functional programs. In Proceedings of ACM Symposium on Principles of Programming Languages, pp. 207–212.Google Scholar
Duggan, D. & Bent, F. (1995) Explaining type inference. Sci. Comput. Program. 27 (1), 3783.Google Scholar
Eo, H., Lee, O. & Yi, K. (2004) Proofs of a set of hybrid let-polymorphic type inference algorithms. New Gener. Comput. 22 (1), 136.Google Scholar
Erwig, M. (2006) Visual Type Inference. J. Vis. Lang. Comput. 17 (2), 161186.CrossRefGoogle Scholar
Erwig, M. & Walkingshaw, E. (2011) The choice calculus: A representation for software variation. ACM Trans. Softw. Eng. Methodol. 21 (1), 6:16:27.Google Scholar
Haack, C. & Wells, J. B. (2003) Type error slicing in implicitly typed higher-order languages. In Proceedings of European Symposium on Programming, pp. 284–301.Google Scholar
Hage, J. (2013) Helium Benchmark Programs (2002–2005). Private communication.Google Scholar
Hage, J. & Heeren, B. (2007) Heuristics for type error discovery and recovery. In Proceedings of Implementation and Application of Functional Languages, pp. 199–216.Google Scholar
Heeren, B., Leijen, D. & van, I. A. (2003) Helium, for learning haskell. In Proceedings of ACM SIGPLAN Workshop on Haskell, pp. 62–71.CrossRefGoogle Scholar
Heeren, B. J. (2005) Top Quality Type Error Messages. Ph.D. thesis, Universiteit Utrecht, The Netherlands.Google Scholar
Johnson, G. F. & Walz, J. A. (1986) A maximum-flow approach to anomaly isolation in unification-based incremental type inference. In Proceedings of ACM Symposium on Principles of Programming Languages, pp. 44–57.Google Scholar
Lee, O. & Yi, K. (1998) Proofs about a folklore let-polymorphic type inference algorithm. ACM Trans. Program. Lang. Syst. 20 (4), 707723.Google Scholar
Lee, O. & Yi, K. (2000) A Generalized Let-Polymorphic Type Inference Algorithm. Tech. rept. Technical Memorandum ROPAS-2000-5, Research on Program Analysis System, Korea Advanced Institute of Science and Technology.Google Scholar
Lerner, B., Flower, M., Grossman, D. & Chambers, C. (2007) Searching for type-error messages. In Proceedings of ACM International Conference on Programming Language Design and Implementation, pp. 425–434.Google Scholar
Lerner, B., Grossman, D. & Chambers, C. (2006) Seminal: Searching for ml type-error messages. In Proceedings of Workshop on ml, pp. 63–73.Google Scholar
Loncaric, C., Chandra, S., Schlesinger, C. & Sridharan, M. (2016). A practical framework for type inference error explanation. In Proceedings of the 2016 Acm Sigplan International Conference on Object-Oriented Programming, Systems, Languages, and Applications. OOPSLA 2016. New York, NY, USA: ACM, pp. 781–799.Google Scholar
McAdam, B. J. (1999). Graphs for Recording Type Information. Technical Report ECS-LFCS-99-415. University of Edinburgh.Google Scholar
McAdam, B. J. (2002a). Reporting Type Errors in Functional Programs. Ph.D. thesis, Larboratory for Foundations of Computer Science, The University of Edinburgh.Google Scholar
McAdam, B. J. (2002b). Repairing Type Errors in Functional Programs. Ph.D. thesis, University of Edinburgh. College of Science and Engineering. School of Informatics.Google Scholar
Neubauer, M. & Thiemann, P. (2003) Discriminative sum types locate the source of type errors. In Proceedings of ACM International Conference on Functional Programming, pp. 15–26Google Scholar
Pavlinovic, Z., King, T. & Wies, T. (2014) Finding minimum type error sources. In Proceedings of ACM International Conference on Object Oriented Programming Systems Languages & Applications, pp. 525–542Google Scholar
Pavlinovic, Z., King, T. & Wies, T. (2015) Practical SMT-based type error localization. In Proceedings of ACM International Conference on Functional Programming, pp. 412–423.CrossRefGoogle Scholar
Pfenning, F. (1991) Unification and anti-unification in the calculus of constructions. In Proceedings of IEEE Symposium on Logic in Computer Science, pp. 74–85.Google Scholar
Schilling, T. (2012) Constraint-free type error slicing. In Proceedings of Trends in Functional Programming. Springer, pp. 1–16.Google Scholar
Seidel, E. L., Jhala, R. & Weimer, W. (2016) Dynamic witnesses for static type errors (or, ill-typed programs usually go wrong). In Proceedings of ACM International Conference on Functional Programming, pp. 228–242.Google Scholar
Seidel, E. L., Sibghat, H., Chaudhuri, K., Weimer, W. & Jhala, R. (2017) Learning to blame: Localizing novice type errors with data-driven diagnosis. Proc. ACM Program. Lang. 1 (OOPSLA), 60:160:27.Google Scholar
Stuckey, P. J., Sulzmann, M. & Wazny, J. (2003) Interactive type debugging in haskell. InProceedings of ACM Sigplan Workshop on Haskell, pp. 72–83.Google Scholar
Tip, F. & Dinesh, T. B. (2001) A slicing-based approach for locating type errors. ACM Trans. Softw. Eng. Methodol., 10 (1), 555.Google Scholar
Tirronen, V., Uusi-mäkelä, S. & Isomöttönen, V. (2015) Understanding beginners' mistakes with Haskell. J. Funct. Program., 25, 131.Google Scholar
Tsushima, K. & Chitil, O. (2014) Enumerating counter-factual type error messages with an existing type checker. In Proceedings of 16th Workshop on Programming and Programming Languages.Google Scholar
Wand, M. (1986) Finding the source of type errors. In Proceedings of ACM Symposium on Principles of Programming Languages, pp. 38–43.Google Scholar
Wazny, J. R. (2006 January) Type Inference and Type Error Diagnosis for Hindley/Milner with Extensions. Ph.D. thesis, The University of Melbourne.Google Scholar
Wu, B. & Chen, S. (2017) How type errors were fixed and what students did? Proc. ACM Program. Lang. 1 (OOPSLA), 105:1105:27.Google Scholar
Wu, B., Campora, John P. III & Chen, S. (2017) Learning user friendly type-error messages. Proc. ACM Program. Lang. 1 (OOPSLA), 106:1106:29.Google Scholar
Yang, J. (2000) Explaining type errors by finding the source of a type conflict. In Proceedings of Trends in Functional Programming. Intellect Books, pp. 58–66.Google Scholar
Yang, J. (2001 May). Improving Polymorphic Type Explanations. Ph.D. thesis, Heriot-Watt University.Google Scholar
Yang, J., Michaelson, G., Trinder, P. & Wells, J. B. (2000) Improved type error reporting. In Proceedings of International Workshop on Implementation of Functional Languages, pp. 71–86.Google Scholar
Zhang, D. & Myers, A. C. (2014) Toward general diagnosis of static errors. In Proceedings of ACM Symposium on Principles of Programming Languages, pp. 569–581.Google Scholar
Zhang, D., Myers, A. C., Vytiniotis, D. & Peyton-Jones, S. (2015) Diagnosing type errors with class. In Proceedings of ACM Conference on Programming Language Design and Implementation, pp. 12–21.Google Scholar
Submit a response

Discussions

No Discussions have been published for this article.