diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index 44c4d1bb2..702295099 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -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", diff --git a/d2ir/compile.go b/d2ir/compile.go index 04754ce48..91c0739e8 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -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 diff --git a/testdata/d2compiler/TestCompile/composite-glob-filter.exp.json b/testdata/d2compiler/TestCompile/composite-glob-filter.exp.json new file mode 100644 index 000000000..f7cc9c42a --- /dev/null +++ b/testdata/d2compiler/TestCompile/composite-glob-filter.exp.json @@ -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" + } + ] + } +}