一句话:提出“合理最通用客户端”概念并实现 REAGENT,检测 JavaScript 库 TypeScript 声明文件中的类型错误。
静态分析库代码时若无法获取客户端代码,常规做法是用最通用客户端抽象建模所有可能客户端。但在 JavaScript 等动态语言中,最通用客户端过于宽泛,可能以库开发者未预期且实际客户端不会采用的方式交互,导致分析结果无用。本文提出“合理最通用客户端”概念,并实现静态分析工具 REAGENT,用于检测 JavaScript 库的 TypeScript 声明文件中的错误。作者将多种合理最通用客户端变体集成到现有 JavaScript 静态分析器中,研究不同客户端行为假设对分析结果的影响。实验表明,REAGENT 能在真实 TypeScript 声明文件中发现类型错误,且在错误修正后,可保证相对于所选假设不再存在剩余错误。
A well-known approach to statically analyze libraries without having access to their client code is to model all possible clients abstractly using a most-general client. In dynamic languages, however, a most-general client would be too general: it may interact with the library in ways that are not intended by the library developer and are not realistic in actual clients, resulting in useless analysis results. In this work, we explore the concept of a reasonably-most-general client, in the context of a new static analysis tool REAGENT that aims to detect errors in TypeScript declaration files for JavaScript libraries. By incorporating different variations of reasonably-most-general clients into an existing static analyzer for JavaScript, we use REAGENT to study how different assumptions of client behavior affect the analysis results. We also show how REAGENT is able to find type errors in real-world TypeScript declaration files, and, once the errors have been corrected, to guarantee that no remaining errors exist relative to the selected assumptions.