Trust, but Verify: Two-Phase Typing for Dynamic Languages

Panagiotis Vekris, B. Cosman, Ranjit Jhala
{"title":"Trust, but Verify: Two-Phase Typing for Dynamic Languages","authors":"Panagiotis Vekris, B. Cosman, Ranjit Jhala","doi":"10.4230/LIPIcs.ECOOP.2015.52","DOIUrl":null,"url":null,"abstract":"A key challenge when statically typing so-called dynamic languages is the ubiquity of value-based overloading, where a given function can dynamically reflect upon and behave according to the types of its arguments. Thus, to establish basic types, the analysis must reason precisely about values, but in the presence of higher-order functions and polymorphism, this reasoning itself can require basic types. In this paper we address this chicken-and-egg problem by introducing the framework of two-phased typing. The first “trust” phase performs classical, i.e. flow-, path- and value-insensitive type checking to assign basic types to various program expressions. When the check inevitably runs into “errors” due to value-insensitivity, it wraps problematic expressions with DEAD-casts, which explicate the trust obligations that must be discharged by the second phase. The second phase uses refinement typing, a flow- and path-sensitive analysis, that decorates the first phase’s types with logical predicates to track value relationships and thereby verify the casts and establish other correctness properties for dynamically typed languages.","PeriodicalId":172012,"journal":{"name":"European Conference on Object-Oriented Programming","volume":"34 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2015-04-01","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"8","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"European Conference on Object-Oriented Programming","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.4230/LIPIcs.ECOOP.2015.52","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 8

Abstract

A key challenge when statically typing so-called dynamic languages is the ubiquity of value-based overloading, where a given function can dynamically reflect upon and behave according to the types of its arguments. Thus, to establish basic types, the analysis must reason precisely about values, but in the presence of higher-order functions and polymorphism, this reasoning itself can require basic types. In this paper we address this chicken-and-egg problem by introducing the framework of two-phased typing. The first “trust” phase performs classical, i.e. flow-, path- and value-insensitive type checking to assign basic types to various program expressions. When the check inevitably runs into “errors” due to value-insensitivity, it wraps problematic expressions with DEAD-casts, which explicate the trust obligations that must be discharged by the second phase. The second phase uses refinement typing, a flow- and path-sensitive analysis, that decorates the first phase’s types with logical predicates to track value relationships and thereby verify the casts and establish other correctness properties for dynamically typed languages.
信任,但要验证:动态语言的两阶段类型
静态类型所谓的动态语言面临的一个关键挑战是无处不在的基于值的重载,在这种重载中,给定的函数可以根据其参数的类型动态反映和行为。因此,为了建立基本类型,分析必须对值进行精确的推理,但是在存在高阶函数和多态性的情况下,这种推理本身可能需要基本类型。在本文中,我们通过引入两阶段类型的框架来解决这个先有鸡还是先有蛋的问题。第一个“信任”阶段执行经典的,即流、路径和值不敏感的类型检查,为各种程序表达式分配基本类型。当检查由于值不敏感而不可避免地遇到“错误”时,它用dead -cast包装有问题的表达式,这解释了第二阶段必须履行的信任义务。第二阶段使用细化类型,这是一种对流和路径敏感的分析,它用逻辑谓词修饰第一阶段的类型,以跟踪值关系,从而验证类型转换,并为动态类型语言建立其他正确性属性。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:604180095
Book学术官方微信