d2ir: fix error handling for composite glob filter
This commit is contained in:
parent
75633193a9
commit
c366dd8a42
3 changed files with 28 additions and 1 deletions
|
|
@ -1714,6 +1714,18 @@ steps: {
|
||||||
assert.Equal(t, 1, len(g.Layers[0].Steps))
|
assert.Equal(t, 1, len(g.Layers[0].Steps))
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "composite-glob-filter",
|
||||||
|
|
||||||
|
text: `
|
||||||
|
*: {
|
||||||
|
&shape: [a; b]
|
||||||
|
}
|
||||||
|
k
|
||||||
|
`,
|
||||||
|
expErr: `d2/testdata/d2compiler/TestCompile/composite-glob-filter.d2:3:3: glob filters cannot be composites
|
||||||
|
d2/testdata/d2compiler/TestCompile/composite-glob-filter.d2:3:3: glob filters cannot be composites`,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "import-nested-var",
|
name: "import-nested-var",
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -796,7 +796,7 @@ func (c *compiler) ampersandFilter(refctx *RefContext) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if len(fa) == 0 {
|
if len(fa) == 0 {
|
||||||
if refctx.Key.Value.ScalarBox().Unbox().ScalarString() == "*" {
|
if refctx.Key.Value.ScalarBox().Unbox() != nil && refctx.Key.Value.ScalarBox().Unbox().ScalarString() == "*" {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// The field/edge has no value for this filter
|
// The field/edge has no value for this filter
|
||||||
|
|
|
||||||
15
testdata/d2compiler/TestCompile/composite-glob-filter.exp.json
generated
vendored
Normal file
15
testdata/d2compiler/TestCompile/composite-glob-filter.exp.json
generated
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"graph": null,
|
||||||
|
"err": {
|
||||||
|
"errs": [
|
||||||
|
{
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile/composite-glob-filter.d2,2:2:8-2:16:22",
|
||||||
|
"errmsg": "d2/testdata/d2compiler/TestCompile/composite-glob-filter.d2:3:3: glob filters cannot be composites"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile/composite-glob-filter.d2,2:2:8-2:16:22",
|
||||||
|
"errmsg": "d2/testdata/d2compiler/TestCompile/composite-glob-filter.d2:3:3: glob filters cannot be composites"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue