错误: 无法将重复的 `Number` 字面量传递给同一个构造函数
作者: keenancrane创建于 2024年5月22日更新于 2024年10月29日
标签kind:bugsystem:stylesystem:substanceannoying-but-importantsystem:compiler
在 Substance 中,字面量有一个奇怪的问题,如果尝试在同一个构造函数的多个参数中传递相同的字面量,图表就会崩溃。例如,考虑以下程序,它会绘制具有指定 (x,y) 坐标的点:
-- example.domain type Point constructor Point( Number x, Number y ) -- example.style canvas { width = 400 height = 400 }
forall Point p; Number x,y
where p := Point(x,y) {
shape C = Circle {
center: (x,y)
r: 2
fillColor: #000
}
}
-- example.substance
Point a := Point(0,1)
Point b := Point(10,11)
Point c := Point(20,21)
这个示例运行正常,生成了沿对角线的三个点:
但是,如果我们将坐标改为第二个点的 x=y,我们将得到这样的结果(中间点消失):
Point a := Point(0,1)
Point b := Point(10,10)
Point c := Point(20,21)同样,如果将点 a 设置为 (0,0) 或点 c 设置为 (20,20),则不会被绘制出来。
内容来源: penrose/penrose