fix shape composite
This commit is contained in:
parent
fffb08a250
commit
b30f9702bd
3 changed files with 25 additions and 1 deletions
|
|
@ -176,7 +176,11 @@ func (c *compiler) compileMap(obj *d2graph.Object, m *d2ir.Map) {
|
|||
}
|
||||
shape := m.GetField("shape")
|
||||
if shape != nil {
|
||||
c.compileField(obj, shape)
|
||||
if shape.Composite != nil {
|
||||
c.errorf(shape.LastPrimaryKey(), "reserved field shape does not accept composite")
|
||||
} else {
|
||||
c.compileField(obj, shape)
|
||||
}
|
||||
}
|
||||
for _, f := range m.Fields {
|
||||
if f.Name == "shape" {
|
||||
|
|
|
|||
|
|
@ -2614,6 +2614,15 @@ object: {
|
|||
`,
|
||||
expErr: `d2/testdata/d2compiler/TestCompile/classes-internal-edge.d2:8:3: classes cannot contain an edge`,
|
||||
},
|
||||
{
|
||||
name: "reserved-composite",
|
||||
text: `shape: sequence_diagram {
|
||||
alice -> bob: What does it mean\nto be well-adjusted?
|
||||
bob -> alice: The ability to play bridge or\ngolf as if they were games.
|
||||
}
|
||||
`,
|
||||
expErr: `d2/testdata/d2compiler/TestCompile/reserved-composite.d2:1:1: reserved field shape does not accept composite`,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
|
|
|||
11
testdata/d2compiler/TestCompile/reserved-composite.exp.json
generated
vendored
Normal file
11
testdata/d2compiler/TestCompile/reserved-composite.exp.json
generated
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"graph": null,
|
||||
"err": {
|
||||
"errs": [
|
||||
{
|
||||
"range": "d2/testdata/d2compiler/TestCompile/reserved-composite.d2,0:0:0-3:1:158",
|
||||
"errmsg": "d2/testdata/d2compiler/TestCompile/reserved-composite.d2:1:1: reserved field shape does not accept composite"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue