commit
a73438072e
3 changed files with 22 additions and 3 deletions
|
|
@ -18,3 +18,4 @@
|
||||||
- Fixes rare possibility of rendered connections being hidden or cut off. [#828](https://github.com/terrastruct/d2/pull/828)
|
- Fixes rare possibility of rendered connections being hidden or cut off. [#828](https://github.com/terrastruct/d2/pull/828)
|
||||||
- Creating nested children within `sql_table` and `class` shapes are now prevented (caused confusion when accidentally done). [#834](https://github.com/terrastruct/d2/pull/834)
|
- Creating nested children within `sql_table` and `class` shapes are now prevented (caused confusion when accidentally done). [#834](https://github.com/terrastruct/d2/pull/834)
|
||||||
- Fixes graph deserialization bug. [#837](https://github.com/terrastruct/d2/pull/837)
|
- Fixes graph deserialization bug. [#837](https://github.com/terrastruct/d2/pull/837)
|
||||||
|
- `steps` with non-map fields could cause panics. [#783](https://github.com/terrastruct/d2/pull/783)
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,8 @@ func (c *compiler) compileScenarios(m *Map) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, sf := range scenarios.Fields {
|
for _, sf := range scenarios.Fields {
|
||||||
if sf.Map() == nil {
|
if sf.Map() == nil || sf.Primary() != nil {
|
||||||
|
c.errorf(sf.References[0].Context.Key, "invalid scenario")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
base := m.CopyBase(sf)
|
base := m.CopyBase(sf)
|
||||||
|
|
@ -59,8 +60,9 @@ func (c *compiler) compileSteps(m *Map) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for i, sf := range steps.Fields {
|
for i, sf := range steps.Fields {
|
||||||
if sf.Map() == nil {
|
if sf.Map() == nil || sf.Primary() != nil {
|
||||||
continue
|
c.errorf(sf.References[0].Context.Key, "invalid step")
|
||||||
|
break
|
||||||
}
|
}
|
||||||
var base *Map
|
var base *Map
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
|
|
|
||||||
|
|
@ -420,6 +420,22 @@ steps: {
|
||||||
assertQuery(t, m, 0, 0, nil, "steps.nuclear.quiche")
|
assertQuery(t, m, 0, 0, nil, "steps.nuclear.quiche")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "steps_panic",
|
||||||
|
run: func(t testing.TB) {
|
||||||
|
_, err := compile(t, `steps: {
|
||||||
|
shape: sql_table
|
||||||
|
id: int {constraint: primary_key}
|
||||||
|
}
|
||||||
|
scenarios: {
|
||||||
|
shape: sql_table
|
||||||
|
hey: int {constraint: primary_key}
|
||||||
|
}`)
|
||||||
|
assert.ErrorString(t, err, `TestCompile/steps/steps_panic.d2:6:3: invalid scenario
|
||||||
|
TestCompile/steps/steps_panic.d2:7:3: invalid scenario
|
||||||
|
TestCompile/steps/steps_panic.d2:2:3: invalid step`)
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "recursive",
|
name: "recursive",
|
||||||
run: func(t testing.TB) {
|
run: func(t testing.TB) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue