fix
This commit is contained in:
parent
36a8aa679a
commit
3afbf724f0
4 changed files with 22 additions and 4 deletions
|
|
@ -210,8 +210,8 @@ func (c *compiler) compileField(obj *d2graph.Object, f *d2ir.Field) {
|
|||
c.compileReserved(&obj.Attributes, f)
|
||||
return
|
||||
} else if f.Name == "style" {
|
||||
if f.Map() == nil {
|
||||
c.errorf(f.LastRef().AST(), `"style" expected to be set to a map, or contain an additional keyword like "style.opacity: 0.4"`)
|
||||
if f.Map() == nil || len(f.Map().Fields) == 0 {
|
||||
c.errorf(f.LastRef().AST(), `"style" expected to be set to a map of key-values, or contain an additional keyword like "style.opacity: 0.4"`)
|
||||
return
|
||||
}
|
||||
c.compileStyle(&obj.Attributes, f.Map())
|
||||
|
|
|
|||
|
|
@ -1700,7 +1700,13 @@ x.a.b`,
|
|||
name: "tail-style",
|
||||
|
||||
text: `myobj.style: 3`,
|
||||
expErr: `d2/testdata/d2compiler/TestCompile/tail-style.d2:1:7: "style" expected to be set to a map, or contain an additional keyword like "style.opacity: 0.4"`,
|
||||
expErr: `d2/testdata/d2compiler/TestCompile/tail-style.d2:1:7: "style" expected to be set to a map of key-values, or contain an additional keyword like "style.opacity: 0.4"`,
|
||||
},
|
||||
{
|
||||
name: "tail-style-map",
|
||||
|
||||
text: `myobj.style: {}`,
|
||||
expErr: `d2/testdata/d2compiler/TestCompile/tail-style-map.d2:1:7: "style" expected to be set to a map of key-values, or contain an additional keyword like "style.opacity: 0.4"`,
|
||||
},
|
||||
{
|
||||
name: "bad-style-nesting",
|
||||
|
|
|
|||
12
testdata/d2compiler/TestCompile/tail-style-map.exp.json
generated
vendored
Normal file
12
testdata/d2compiler/TestCompile/tail-style-map.exp.json
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"graph": null,
|
||||
"err": {
|
||||
"ioerr": null,
|
||||
"errs": [
|
||||
{
|
||||
"range": "d2/testdata/d2compiler/TestCompile/tail-style-map.d2,0:6:6-0:11:11",
|
||||
"errmsg": "d2/testdata/d2compiler/TestCompile/tail-style-map.d2:1:7: \"style\" expected to be set to a map of key-values, or contain an additional keyword like \"style.opacity: 0.4\""
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
2
testdata/d2compiler/TestCompile/tail-style.exp.json
generated
vendored
2
testdata/d2compiler/TestCompile/tail-style.exp.json
generated
vendored
|
|
@ -5,7 +5,7 @@
|
|||
"errs": [
|
||||
{
|
||||
"range": "d2/testdata/d2compiler/TestCompile/tail-style.d2,0:6:6-0:11:11",
|
||||
"errmsg": "d2/testdata/d2compiler/TestCompile/tail-style.d2:1:7: \"style\" expected to be set to a map, or contain an additional keyword like \"style.opacity: 0.4\""
|
||||
"errmsg": "d2/testdata/d2compiler/TestCompile/tail-style.d2:1:7: \"style\" expected to be set to a map of key-values, or contain an additional keyword like \"style.opacity: 0.4\""
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue