Hostname: page-component-6766d58669-h8lrw Total loading time: 0 Render date: 2026-05-16T06:41:55.078Z Has data issue: false hasContentIssue false

Static Blame for gradual typing

Published online by Cambridge University Press:  25 March 2024

CHENGHAO SU
Affiliation:
State Key Laboratory for Novel Software Technology, Nanjing University, China (e-mail: chenghao_su@smail.nju.edu.cn)
LIN CHEN
Affiliation:
State Key Laboratory for Novel Software Technology, Nanjing University, China (e-mail: lchen@nju.edu.cn)
LI YANHUI
Affiliation:
State Key Laboratory for Novel Software Technology, Nanjing University, China (e-mail: yanhuili@nju.edu.cn)
YUMING ZHOU
Affiliation:
State Key Laboratory for Novel Software Technology, Nanjing University, China (e-mail: zhouyuming@nju.edu.cn)
Rights & Permissions [Opens in a new window]

Abstract

Gradual typing integrates static and dynamic typing by introducing a dynamic type and a consistency relation. A problem of gradual type systems is that dynamic types can easily hide erroneous data flows since consistency relations are not transitive. Therefore, a more rigorous static check is required to reveal these hidden data flows statically. However, in order to preserve the expressiveness of gradually typed languages, static checks for gradually typed languages cannot simply reject programs with potentially erroneous data flows. By contrast, a more reasonable request is to show how these data flows can affect the execution of the program. In this paper, we propose and formalize Static Blame, a framework that can reveal hidden data flows for gradually typed programs and establish the correspondence between static-time data flows and runtime behavior. With this correspondence, we build a classification of potential errors detected from hidden data flows and formally characterize the possible impact of potential errors in each category on program execution, without simply rejecting the whole program. We implemented Static Blame on Grift, an academic gradually typed language, and evaluated the effectiveness of Static Blame by mutation analysis to verify our theoretical results. Our findings revealed that Static Blame exhibits a notable level of precision and recall in detecting type-related bugs. Furthermore, we conducted a manual classification to elucidate the reasons behind instances of failure. We also evaluated the performance of Static Blame, showing a quadratic growth in run time as program size increases.

Information

Type
Research Article
Creative Commons
Creative Common License - CCCreative Common License - BY
This is an Open Access article, distributed under the terms of the Creative Commons Attribution licence (https://creativecommons.org/licenses/by/4.0/), which permits unrestricted re-use, distribution and reproduction, provided the original article is properly cited.
Copyright
© The Author(s), 2024. Published by Cambridge University Press
Figure 0

Fig. 1. Syntax of $\lambda_\star$ and $\lambda_B.$

Figure 1

Fig. 2. Static semantics of $\lambda_\star.$

Figure 2

Fig. 3. The language $\lambda_B.$

Figure 3

Fig. 4. Syntax for labeled type and type flow.

Figure 4

Fig. 5. Dummy type flow generation for $\lambda_B.$

Figure 5

Fig. 6. Type flow analysis.

Figure 6

Table 1. Summary of mutators

Figure 7

Table 2. Generated legal scenarios and metrics about source programs

Figure 8

Table 3. Effectiveness evaluation of SLOG

Figure 9

Table 4. Cause of false positives and false negatives

Figure 10

Fig. 7. SLOG performance with respect to program size.

Figure 11

Fig. 8. SLOG performance with respect to the proportion of typed code.

Figure 12

Fig. 9. Number of type flows with respect to the proportion of type annotation.

Submit a response

Discussions

No Discussions have been published for this article.