In recent years, researchers have explored component-based synthesis, which aims to automatically construct programs that operate by composing calls to existing APIs. However, prior work has not considered efficient synthesis of methods with side effects, e.g., web app methods that update a database. In this paper, we introduce RbSyn, a novel type- and effect-guided synthesis tool for Ruby. An RbSyn synthesis goal is specified as the type for the target method and a series of test cases it must pass. RbSyn works by recursively generating well-typed candidate method bodies whose write effects match the read effects of the test case assertions. After finding a set of candidates that separately satisfy each test, RbSyn synthesizes a solution that branches to execute the correct candidate code under the appropriate conditions. We formalize RbSyn on a core, object-oriented language $\lambda_{syn}$ and describe how the key ideas of the model are scaled-up in our implementation for Ruby. We evaluated RbSyn on 19 benchmarks, 12 of which come from popular, open-source Ruby apps. We found that RbSyn synthesizes correct solutions for all benchmarks, with 15 benchmarks synthesizing in under 9 seconds, while the slowest benchmark takes 83 seconds. Using observed reads to guide synthesize is effective: using type-guidance alone times out on 10 of 12 app benchmarks. We also found that using less precise effect annotations leads to worse synthesis performance. In summary, we believe type- and effect-guided synthesis is an important step forward in synthesis of effectful methods from test cases.
翻译:近年来,研究人员探索了基于组件的合成,目的是自动构建通过向现有API发送电话而运作的程序。然而,先前的工作并未考虑对具有副作用的方法进行高效的合成,例如更新数据库的网络应用方法。在本论文中,我们为Ruby引入了RbSyn,这是一个新的类型和效果指导合成工具。RbSyn合成目标被指定为目标方法的类型和必须通过的一系列测试案例。RbSyn工作通过反复生成与测试案例的读写效果相匹配的正确类型候选方法机构来进行运行。在找到一套单独满足每次测试的、具有副作用的候选者之后,RbSyn综合了一个在适当条件下执行正确候选人代码的解决方案。我们将RbSyn正规化为核心、目标导向的语言 $\lambda ⁇ syn} 。 RbSyn合成目标被指定为目标方法的类型类型类型和测试案例系列。我们用19个基准来评估RbSyn,其中12个基准的写法来自普通、开源的缩略缩缩缩图。我们发现,在使用正确基准第15秒内,我们用精确的缩缩缩缩缩缩的缩写基准,在基准中,在10秒内,我们用精确的缩写基准中发现所有基准。