一句话:提出 Stellar 框架,通过提升核心语言类型规则,在表层语法中精确定位并报告可修复的语法糖类型错误。
语法糖通过表层语言提供直观语法来提升核心语言可用性,但其与核心语言类型检查器的交互常导致表层程序员难以理解的类型错误。现有类型提升技术能自动推断语法糖的类型规则,却无法直接在表层语法中定位错误。本文研究语法糖类型错误的定位与报告问题,应对精确定位与保证可修复两个挑战。受 marked lambda calculus (MLC) 启发,作者提出带错误来源和位置追踪的核心语言 ℓMLC,并在此基础上设计 Stellar 框架:自动将核心语言类型规则提升到表层语言,在表层语法中实现错误定位,同时通过在提升规则中加入额外前提保证报错可修复。作者实现 Stellar,并在多种具有不同类型结构的表层语言上评估,结果表明该方法能精确定位错误,避免无帮助地引用核心语言构造,帮助表层程序员更有效地处理类型错误,提升语法糖在语言工程中的实用性。
Syntactic sugar enhances the usability of a core language by providing intuitive syntax in a surface language; however, its interaction with the core-language type checker often results in error messages that are unclear to surface programmers. Existing techniques, such as type lifting, can automatically infer typing rules for syntactic sugar, but they do not consider localizing type errors directly in the surface syntax. This paper studies the problem of localizing and reporting type errors for syntactic sugar, addressing two key challenges: precisely localizing errors and ensuring that they are fixable. Inspired by the recently proposed marked lambda calculus (MLC), we develop ℓ MLC as our core language which tracks error provenance and locations via type annotations. Building on this, we propose the Ste llar framework, which automatically lifts the core language’s typing rules to the surface language while enabling error localization in the surface syntax. Ste llar also ensures that the reported errors are fixable by incorporating extra premises into the lifted typing rules. We implement Ste llar and evaluate it across various surface languages with different type structures, demonstrating that our approach precisely localizes errors and avoids unhelpful references to core-language constructs. Our evaluation suggests that Ste llar can help surface programmers address type errors more effectively, enhancing the practicality of syntactic sugar in language engineering.
@article{paperbot3822,
title = {Localizing Type Errors for Syntactic Sugar by Lifting},
author = {Zhichao Guan and Tailai Yu and Di Wang and Zhenjiang Hu},
journal = {Proceedings of the ACM on Programming Languages},
volume = {10},
number = {OOPSLA1},
year = {2026},
doi = {10.1145/3798253}
}