diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 2c16f2451..bc2ea0d5c 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -24,6 +24,7 @@ - fixes support for `center` in `d2-config` [#2360](https://github.com/terrastruct/d2/pull/2360) - fixes panic when comment lines appear in arrays [#2378](https://github.com/terrastruct/d2/pull/2378) - 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) - CLI: fetch and render remote images of mimetype octet-stream correctly [#2370](https://github.com/terrastruct/d2/pull/2370) - d2js: handle unicode characters [#2393](https://github.com/terrastruct/d2/pull/2393) diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index c64c18919..ccd042fad 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -3141,6 +3141,44 @@ x*: { tassert.Equal(t, "x2.ok", g.Objects[3].AbsID()) }, }, + { + name: "glob-spread-vars/1", + text: `vars: { + b: { + 1 + } +} + +a: { + ...${b} + *.style.fill: red +} +`, + assertions: func(t *testing.T, g *d2graph.Graph) { + assert.Equal(t, "1", g.Objects[1].Label.Value) + assert.Equal(t, "red", g.Objects[1].Style.Fill.Value) + }, + }, + { + name: "glob-spread-vars/2", + text: `vars: { + b: { + 1 + 2 + } +} + +a: { + ...${b} + ** -> _.ok +} + +ok +`, + assertions: func(t *testing.T, g *d2graph.Graph) { + assert.Equal(t, 2, len(g.Edges)) + }, + }, { name: "import-var-chain", diff --git a/d2ir/compile.go b/d2ir/compile.go index 82f3559d1..19a77c037 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -280,6 +280,19 @@ func (c *compiler) resolveSubstitutions(varsStack []*Map, node Node) (removedFie break } } + + if removedField && len(m.globs) > 0 && !c.lazyGlobBeingApplied { + origGlobStack := c.globContextStack + c.globContextStack = append(c.globContextStack, m.globs) + for _, gctx := range m.globs { + old := c.lazyGlobBeingApplied + c.lazyGlobBeingApplied = true + c.compileKey(gctx.refctx) + c.lazyGlobBeingApplied = old + } + c.globContextStack = origGlobStack + } + } } if resolvedField.Primary() == nil { diff --git a/testdata/d2compiler/TestCompile/glob-spread-vars.exp.json b/testdata/d2compiler/TestCompile/glob-spread-vars.exp.json new file mode 100644 index 000000000..183600210 --- /dev/null +++ b/testdata/d2compiler/TestCompile/glob-spread-vars.exp.json @@ -0,0 +1,319 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,0:0:0-10:0:65", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,0:0:0-4:1:26", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,0:0:0-0:4:4", + "value": [ + { + "string": "vars", + "raw_string": "vars" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,0:6:6-4:1:26", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,1:2:10-3:3:24", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,1:2:10-1:3:11", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,1:2:10-1:3:11", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,1:5:13-3:3:24", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,2:4:19-2:5:20", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,2:4:19-2:5:20", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,2:4:19-2:5:20", + "value": [ + { + "string": "1", + "raw_string": "1" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,6:0:28-9:1:64", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,6:0:28-6:1:29", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,6:0:28-6:1:29", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,6:3:31-9:1:64", + "nodes": [ + { + "substitution": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,7:2:35-7:9:42", + "spread": true, + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,7:7:40-7:8:41", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,8:2:45-8:19:62", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,8:2:45-8:14:57", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,8:2:45-8:3:46", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,8:4:47-8:9:52", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,8:10:53-8:14:57", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,8:16:59-8:19:62", + "value": [ + { + "string": "red", + "raw_string": "red" + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + "edges": null, + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,6:0:28-6:1:29", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,6:0:28-6:1:29", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "id": "1", + "id_val": "1", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,2:4:19-2:5:20", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars.d2,2:4:19-2:5:20", + "value": [ + { + "string": "1", + "raw_string": "1" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "1" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": { + "fill": { + "value": "red" + } + }, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + }, + "err": null +} diff --git a/testdata/d2compiler/TestCompile/glob-spread-vars/1.exp.json b/testdata/d2compiler/TestCompile/glob-spread-vars/1.exp.json new file mode 100644 index 000000000..b973d1850 --- /dev/null +++ b/testdata/d2compiler/TestCompile/glob-spread-vars/1.exp.json @@ -0,0 +1,319 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,0:0:0-10:0:65", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,0:0:0-4:1:26", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,0:0:0-0:4:4", + "value": [ + { + "string": "vars", + "raw_string": "vars" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,0:6:6-4:1:26", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,1:2:10-3:3:24", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,1:2:10-1:3:11", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,1:2:10-1:3:11", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,1:5:13-3:3:24", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,2:4:19-2:5:20", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,2:4:19-2:5:20", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,2:4:19-2:5:20", + "value": [ + { + "string": "1", + "raw_string": "1" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,6:0:28-9:1:64", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,6:0:28-6:1:29", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,6:0:28-6:1:29", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,6:3:31-9:1:64", + "nodes": [ + { + "substitution": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,7:2:35-7:9:42", + "spread": true, + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,7:7:40-7:8:41", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,8:2:45-8:19:62", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,8:2:45-8:14:57", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,8:2:45-8:3:46", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,8:4:47-8:9:52", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,8:10:53-8:14:57", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,8:16:59-8:19:62", + "value": [ + { + "string": "red", + "raw_string": "red" + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + "edges": null, + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,6:0:28-6:1:29", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,6:0:28-6:1:29", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "id": "1", + "id_val": "1", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,2:4:19-2:5:20", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/1.d2,2:4:19-2:5:20", + "value": [ + { + "string": "1", + "raw_string": "1" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "1" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": { + "fill": { + "value": "red" + } + }, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + }, + "err": null +} diff --git a/testdata/d2compiler/TestCompile/glob-spread-vars/2.exp.json b/testdata/d2compiler/TestCompile/glob-spread-vars/2.exp.json new file mode 100644 index 000000000..52b3ca111 --- /dev/null +++ b/testdata/d2compiler/TestCompile/glob-spread-vars/2.exp.json @@ -0,0 +1,578 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,0:0:0-13:0:66", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,0:0:0-5:1:30", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,0:0:0-0:4:4", + "value": [ + { + "string": "vars", + "raw_string": "vars" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,0:6:6-5:1:30", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,1:2:10-4:3:28", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,1:2:10-1:3:11", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,1:2:10-1:3:11", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,1:5:13-4:3:28", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,2:4:19-2:5:20", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,2:4:19-2:5:20", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,2:4:19-2:5:20", + "value": [ + { + "string": "1", + "raw_string": "1" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,3:2:23-3:3:24", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,3:2:23-3:3:24", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,3:2:23-3:3:24", + "value": [ + { + "string": "2", + "raw_string": "2" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,7:0:32-10:1:61", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,7:0:32-7:1:33", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,7:0:32-7:1:33", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,7:3:35-10:1:61", + "nodes": [ + { + "substitution": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,8:2:39-8:9:46", + "spread": true, + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,8:7:44-8:8:45", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,9:2:49-9:12:59", + "edges": [ + { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,9:2:49-9:12:59", + "src": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,9:2:49-9:4:51", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,9:2:49-9:4:51", + "value": [ + { + "string": "**", + "raw_string": "**" + } + ], + "pattern": [ + "*", + "", + "*" + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,9:8:55-9:12:59", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,9:8:55-9:9:56", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,9:10:57-9:12:59", + "value": [ + { + "string": "ok", + "raw_string": "ok" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,12:0:63-12:2:65", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,12:0:63-12:2:65", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,12:0:63-12:2:65", + "value": [ + { + "string": "ok", + "raw_string": "ok" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,7:0:32-7:1:33", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,7:0:32-7:1:33", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "id": "1", + "id_val": "1", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,2:4:19-2:5:20", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,2:4:19-2:5:20", + "value": [ + { + "string": "1", + "raw_string": "1" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "1" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "id": "2", + "id_val": "2", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,3:2:23-3:3:24", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,3:2:23-3:3:24", + "value": [ + { + "string": "2", + "raw_string": "2" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "2" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "id": "ok", + "id_val": "ok", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,9:8:55-9:12:59", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,9:8:55-9:9:56", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,9:10:57-9:12:59", + "value": [ + { + "string": "ok", + "raw_string": "ok" + } + ] + } + } + ] + }, + "key_path_index": 1, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,12:0:63-12:2:65", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,12:0:63-12:2:65", + "value": [ + { + "string": "ok", + "raw_string": "ok" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,9:8:55-9:12:59", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,9:8:55-9:9:56", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/glob-spread-vars/2.d2,9:10:57-9:12:59", + "value": [ + { + "string": "ok", + "raw_string": "ok" + } + ] + } + } + ] + }, + "key_path_index": 1, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "ok" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + }, + "err": null +}