Merge pull request #2489 from alixander/fix-glob-filter
d2ir: fix error handling for composite glob filter
This commit is contained in:
commit
e325fa23cc
4 changed files with 29 additions and 1 deletions
|
|
@ -36,6 +36,7 @@
|
|||
- fixes inconsistencies when objects were double quoted [#2390](https://github.com/terrastruct/d2/pull/2390)
|
||||
- fixes globs not applying to spread substitutions [#2426](https://github.com/terrastruct/d2/issues/2426)
|
||||
- fixes panic when classes were mixed with layers incorrectly [#2448](https://github.com/terrastruct/d2/pull/2448)
|
||||
- fixes panic using glob ampersand filters with composite values [#2489](https://github.com/terrastruct/d2/pull/2489)
|
||||
- Formatter:
|
||||
- fixes substitutions in quotes surrounded by text [#2462](https://github.com/terrastruct/d2/pull/2462)
|
||||
- CLI: fetch and render remote images of mimetype octet-stream correctly [#2370](https://github.com/terrastruct/d2/pull/2370)
|
||||
|
|
|
|||
|
|
@ -1714,6 +1714,18 @@ 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",
|
||||
|
||||
|
|
|
|||
|
|
@ -796,7 +796,7 @@ func (c *compiler) ampersandFilter(refctx *RefContext) bool {
|
|||
return false
|
||||
}
|
||||
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
|
||||
}
|
||||
// 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