d2ir: enable linking beyond board root

This commit is contained in:
Alexander Wang 2024-08-26 13:43:56 -06:00
parent 9cc7a04c15
commit a72126ae51
No known key found for this signature in database
GPG key ID: BE3937D0D52D8927
9 changed files with 2973 additions and 7 deletions

View file

@ -1,6 +1,8 @@
#### Features 🚀
- Vars: Variable definitions can now refer to other variables in the current scope [#2052](https://github.com/terrastruct/d2/pull/2052)
- Composition: Imported boards can use underscores to reference boards beyond its own
scope (e.g. to a sibling board at the scope its imported to) [#2075](https://github.com/terrastruct/d2/pull/2075)
#### Improvements 🧹

View file

@ -2394,7 +2394,7 @@ layers: {
}
}
}`,
expErr: `d2/testdata/d2compiler/TestCompile/link-board-underscore-not-found.d2:7:9: invalid underscore usage`,
expErr: `d2/testdata/d2compiler/TestCompile/link-board-underscore-not-found.d2:7:9: linked board not found`,
},
{
name: "border-radius-negative",
@ -3114,6 +3114,80 @@ layers: {
"y/n.d2": "p",
},
},
{
name: "import-link-layer-1",
text: `k
layers: {
x: {...@y}
z: { hi }
}`,
files: map[string]string{
"y.d2": `a.link: _.layers.z
`,
},
assertions: func(t *testing.T, g *d2graph.Graph) {
tassert.Equal(t, "root.layers.z", g.Layers[0].Objects[0].Link.Value)
},
},
{
name: "import-link-layer-2",
text: `...@y
layers: {
z: { hi }
}`,
files: map[string]string{
"y.d2": `a.link: layers.z
`,
},
assertions: func(t *testing.T, g *d2graph.Graph) {
tassert.Equal(t, "root.layers.z", g.Objects[0].Link.Value)
},
},
{
name: "import-link-layer-3",
text: `k
layers: {
x: {...@y}
z: { hi }
}`,
files: map[string]string{
"y.d2": `a
layers: {
lol: {
asdf.link: _._.layers.z
}
}
`,
},
assertions: func(t *testing.T, g *d2graph.Graph) {
tassert.Equal(t, "root.layers.z", g.Layers[0].Layers[0].Objects[0].Link.Value)
},
},
{
name: "import-link-layer-4",
text: `k
layers: {
x: @y
z: { hi }
}`,
files: map[string]string{
"y.d2": `a
layers: {
lol: {
asdf.link: _.layers.z
}
z: { fjf }
}
`,
},
assertions: func(t *testing.T, g *d2graph.Graph) {
tassert.Equal(t, "root.layers.x.layers.z", g.Layers[0].Layers[0].Objects[0].Link.Value)
},
},
{
name: "sql-table-header-newline",
text: `x: {

View file

@ -920,6 +920,15 @@ func (c *compiler) extendLinks(m *Map, importF *Field, importDir string) {
continue
}
for _, id := range linkIDA[1:] {
if id == "_" {
linkIDA = append([]string{linkIDA[0]}, linkIDA[2:]...)
importIDA = importIDA[:len(importIDA)-2]
} else {
break
}
}
extendedIDA := append(importIDA, linkIDA[1:]...)
kp := d2ast.MakeKeyPath(extendedIDA)
s := d2format.Format(kp)
@ -984,10 +993,9 @@ func (c *compiler) compileLink(f *Field, refctx *RefContext) {
// Resolve underscores
for len(linkIDA) > 0 && linkIDA[0] == "_" {
if len(scopeIDA) < 2 {
// IR compiler only validates bad underscore usage
// The compiler will validate if the target board actually exists
c.errorf(refctx.Key.Key, "invalid underscore usage")
return
// Leave the underscore. It will fail in compiler as a standalone board,
// but if imported, will get further resolved in extendLinks
break
}
// pop 2 off path per one underscore
scopeIDA = scopeIDA[:len(scopeIDA)-2]

View file

@ -0,0 +1,493 @@
{
"graph": {
"name": "",
"isFolderOnly": false,
"ast": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-1.d2,0:0:0-5:1:39",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-1.d2,0:0:0-0:1:1",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-1.d2,0:0:0-0:1:1",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-1.d2,0:0:0-0:1:1",
"value": [
{
"string": "k",
"raw_string": "k"
}
]
}
}
]
},
"primary": {},
"value": {}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-1.d2,2:0:3-5:1:39",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-1.d2,2:0:3-2:6:9",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-1.d2,2:0:3-2:6:9",
"value": [
{
"string": "layers",
"raw_string": "layers"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-1.d2,2:8:11-5:1:39",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-1.d2,3:2:15-3:12:25",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-1.d2,3:2:15-3:3:16",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-1.d2,3:2:15-3:3:16",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-1.d2,3:5:18-3:12:25",
"nodes": [
{
"import": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-1.d2,3:6:19-3:11:24",
"spread": true,
"pre": "",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-1.d2,3:10:23-3:11:24",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
}
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-1.d2,4:2:28-4:11:37",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-1.d2,4:2:28-4:3:29",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-1.d2,4:2:28-4:3:29",
"value": [
{
"string": "z",
"raw_string": "z"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-1.d2,4:5:31-4:11:37",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-1.d2,4:7:33-4:10:36",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-1.d2,4:7:33-4:9:35",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-1.d2,4:7:33-4:9:35",
"value": [
{
"string": "hi",
"raw_string": "hi"
}
]
}
}
]
},
"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": null,
"objects": [
{
"id": "k",
"id_val": "k",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-1.d2,0:0:0-0:1:1",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-1.d2,0:0:0-0:1:1",
"value": [
{
"string": "k",
"raw_string": "k"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "k"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
],
"layers": [
{
"name": "x",
"isFolderOnly": false,
"ast": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "a"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "link"
}
]
}
}
]
},
"primary": {
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "root.layers.z"
}
]
}
},
"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": null,
"objects": [
{
"id": "a",
"id_val": "a",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/y.d2,0:0:0-0:6:6",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/y.d2,0:0:0-0:1:1",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/y.d2,0:2:2-0:6:6",
"value": [
{
"string": "link",
"raw_string": "link"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "a"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"link": {
"value": "root.layers.z"
},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
]
},
{
"name": "z",
"isFolderOnly": false,
"ast": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "hi"
}
]
}
}
]
},
"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": null,
"objects": [
{
"id": "hi",
"id_val": "hi",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-1.d2,4:7:33-4:9:35",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-1.d2,4:7:33-4:9:35",
"value": [
{
"string": "hi",
"raw_string": "hi"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "hi"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
]
}
]
},
"err": null
}

View file

@ -0,0 +1,302 @@
{
"graph": {
"name": "",
"isFolderOnly": false,
"ast": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-2.d2,0:0:0-4:1:30",
"nodes": [
{
"import": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-2.d2,0:0:0-0:5:5",
"spread": true,
"pre": "",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-2.d2,0:4:4-0:5:5",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-2.d2,2:0:7-4:1:30",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-2.d2,2:0:7-2:6:13",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-2.d2,2:0:7-2:6:13",
"value": [
{
"string": "layers",
"raw_string": "layers"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-2.d2,2:8:15-4:1:30",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-2.d2,3:2:19-3:11:28",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-2.d2,3:2:19-3:3:20",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-2.d2,3:2:19-3:3:20",
"value": [
{
"string": "z",
"raw_string": "z"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-2.d2,3:5:22-3:11:28",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-2.d2,3:7:24-3:10:27",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-2.d2,3:7:24-3:9:26",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-2.d2,3:7:24-3:9:26",
"value": [
{
"string": "hi",
"raw_string": "hi"
}
]
}
}
]
},
"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": null,
"objects": [
{
"id": "a",
"id_val": "a",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/y.d2,0:0:0-0:6:6",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/y.d2,0:0:0-0:1:1",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/y.d2,0:2:2-0:6:6",
"value": [
{
"string": "link",
"raw_string": "link"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "a"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"link": {
"value": "root.layers.z"
},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
],
"layers": [
{
"name": "z",
"isFolderOnly": false,
"ast": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "hi"
}
]
}
}
]
},
"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": null,
"objects": [
{
"id": "hi",
"id_val": "hi",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-2.d2,3:7:24-3:9:26",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-2.d2,3:7:24-3:9:26",
"value": [
{
"string": "hi",
"raw_string": "hi"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "hi"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
]
}
]
},
"err": null
}

View file

@ -0,0 +1,712 @@
{
"graph": {
"name": "",
"isFolderOnly": false,
"ast": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-3.d2,0:0:0-5:1:39",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-3.d2,0:0:0-0:1:1",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-3.d2,0:0:0-0:1:1",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-3.d2,0:0:0-0:1:1",
"value": [
{
"string": "k",
"raw_string": "k"
}
]
}
}
]
},
"primary": {},
"value": {}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-3.d2,2:0:3-5:1:39",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-3.d2,2:0:3-2:6:9",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-3.d2,2:0:3-2:6:9",
"value": [
{
"string": "layers",
"raw_string": "layers"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-3.d2,2:8:11-5:1:39",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-3.d2,3:2:15-3:12:25",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-3.d2,3:2:15-3:3:16",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-3.d2,3:2:15-3:3:16",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-3.d2,3:5:18-3:12:25",
"nodes": [
{
"import": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-3.d2,3:6:19-3:11:24",
"spread": true,
"pre": "",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-3.d2,3:10:23-3:11:24",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
}
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-3.d2,4:2:28-4:11:37",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-3.d2,4:2:28-4:3:29",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-3.d2,4:2:28-4:3:29",
"value": [
{
"string": "z",
"raw_string": "z"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-3.d2,4:5:31-4:11:37",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-3.d2,4:7:33-4:10:36",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-3.d2,4:7:33-4:9:35",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-3.d2,4:7:33-4:9:35",
"value": [
{
"string": "hi",
"raw_string": "hi"
}
]
}
}
]
},
"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": null,
"objects": [
{
"id": "k",
"id_val": "k",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-3.d2,0:0:0-0:1:1",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-3.d2,0:0:0-0:1:1",
"value": [
{
"string": "k",
"raw_string": "k"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "k"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
],
"layers": [
{
"name": "x",
"isFolderOnly": false,
"ast": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "a"
}
]
}
}
]
},
"primary": {},
"value": {}
}
},
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "layers"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "lol"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "asdf"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "link"
}
]
}
}
]
},
"primary": {
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "root.layers.z"
}
]
}
},
"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": null,
"objects": [
{
"id": "a",
"id_val": "a",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/y.d2,0:0:0-0:1:1",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/y.d2,0:0:0-0:1:1",
"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
}
],
"layers": [
{
"name": "lol",
"isFolderOnly": false,
"ast": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "asdf"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "link"
}
]
}
}
]
},
"primary": {
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "root.layers.z"
}
]
}
},
"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": null,
"objects": [
{
"id": "asdf",
"id_val": "asdf",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/y.d2,3:4:25-3:13:34",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/y.d2,3:4:25-3:8:29",
"value": [
{
"string": "asdf",
"raw_string": "asdf"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/y.d2,3:9:30-3:13:34",
"value": [
{
"string": "link",
"raw_string": "link"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "asdf"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"link": {
"value": "root.layers.z"
},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
]
}
]
},
{
"name": "z",
"isFolderOnly": false,
"ast": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "hi"
}
]
}
}
]
},
"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": null,
"objects": [
{
"id": "hi",
"id_val": "hi",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-3.d2,4:7:33-4:9:35",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-3.d2,4:7:33-4:9:35",
"value": [
{
"string": "hi",
"raw_string": "hi"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "hi"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
]
}
]
},
"err": null
}

View file

@ -0,0 +1,882 @@
{
"graph": {
"name": "",
"isFolderOnly": false,
"ast": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-4.d2,0:0:0-5:1:34",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-4.d2,0:0:0-0:1:1",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-4.d2,0:0:0-0:1:1",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-4.d2,0:0:0-0:1:1",
"value": [
{
"string": "k",
"raw_string": "k"
}
]
}
}
]
},
"primary": {},
"value": {}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-4.d2,2:0:3-5:1:34",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-4.d2,2:0:3-2:6:9",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-4.d2,2:0:3-2:6:9",
"value": [
{
"string": "layers",
"raw_string": "layers"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-4.d2,2:8:11-5:1:34",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-4.d2,3:2:15-3:7:20",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-4.d2,3:2:15-3:3:16",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-4.d2,3:2:15-3:3:16",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",1:0:0-1:0:0",
"nodes": [
{
"import": {
"range": ",1:0:0-1:0:0",
"spread": true,
"pre": "",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-4.d2,3:6:19-3:7:20",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
}
}
]
},
"import": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-4.d2,3:5:18-3:7:20",
"spread": false,
"pre": "",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-4.d2,3:6:19-3:7:20",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-4.d2,4:2:23-4:11:32",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-4.d2,4:2:23-4:3:24",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-4.d2,4:2:23-4:3:24",
"value": [
{
"string": "z",
"raw_string": "z"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-4.d2,4:5:26-4:11:32",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-4.d2,4:7:28-4:10:31",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-4.d2,4:7:28-4:9:30",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-4.d2,4:7:28-4:9:30",
"value": [
{
"string": "hi",
"raw_string": "hi"
}
]
}
}
]
},
"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": null,
"objects": [
{
"id": "k",
"id_val": "k",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-4.d2,0:0:0-0:1:1",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-4.d2,0:0:0-0:1:1",
"value": [
{
"string": "k",
"raw_string": "k"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "k"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
],
"layers": [
{
"name": "x",
"isFolderOnly": false,
"ast": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "a"
}
]
}
}
]
},
"primary": {},
"value": {}
}
},
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "layers"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "lol"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "asdf"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "link"
}
]
}
}
]
},
"primary": {
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "root.layers.x.layers.z"
}
]
}
},
"value": {}
}
}
]
}
}
}
}
]
}
}
}
},
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "z"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "fjf"
}
]
}
}
]
},
"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": null,
"objects": [
{
"id": "a",
"id_val": "a",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/y.d2,0:0:0-0:1:1",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/y.d2,0:0:0-0:1:1",
"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
}
],
"layers": [
{
"name": "lol",
"isFolderOnly": false,
"ast": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "asdf"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "link"
}
]
}
}
]
},
"primary": {
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "root.layers.x.layers.z"
}
]
}
},
"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": null,
"objects": [
{
"id": "asdf",
"id_val": "asdf",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/y.d2,3:4:25-3:13:34",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/y.d2,3:4:25-3:8:29",
"value": [
{
"string": "asdf",
"raw_string": "asdf"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/y.d2,3:9:30-3:13:34",
"value": [
{
"string": "link",
"raw_string": "link"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "asdf"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"link": {
"value": "root.layers.x.layers.z"
},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
]
},
{
"name": "z",
"isFolderOnly": false,
"ast": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "fjf"
}
]
}
}
]
},
"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": null,
"objects": [
{
"id": "fjf",
"id_val": "fjf",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/y.d2,5:6:57-5:9:60",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/y.d2,5:6:57-5:9:60",
"value": [
{
"string": "fjf",
"raw_string": "fjf"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "fjf"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
]
}
]
},
{
"name": "z",
"isFolderOnly": false,
"ast": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "hi"
}
]
}
}
]
},
"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": null,
"objects": [
{
"id": "hi",
"id_val": "hi",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-4.d2,4:7:28-4:9:30",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-layer-4.d2,4:7:28-4:9:30",
"value": [
{
"string": "hi",
"raw_string": "hi"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "hi"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
]
}
]
},
"err": null
}

View file

@ -0,0 +1,493 @@
{
"graph": {
"name": "",
"isFolderOnly": false,
"ast": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-sibling-layer.d2,0:0:0-5:1:39",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-sibling-layer.d2,0:0:0-0:1:1",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-sibling-layer.d2,0:0:0-0:1:1",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-sibling-layer.d2,0:0:0-0:1:1",
"value": [
{
"string": "k",
"raw_string": "k"
}
]
}
}
]
},
"primary": {},
"value": {}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-sibling-layer.d2,2:0:3-5:1:39",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-sibling-layer.d2,2:0:3-2:6:9",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-sibling-layer.d2,2:0:3-2:6:9",
"value": [
{
"string": "layers",
"raw_string": "layers"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-sibling-layer.d2,2:8:11-5:1:39",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-sibling-layer.d2,3:2:15-3:12:25",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-sibling-layer.d2,3:2:15-3:3:16",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-sibling-layer.d2,3:2:15-3:3:16",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-sibling-layer.d2,3:5:18-3:12:25",
"nodes": [
{
"import": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-sibling-layer.d2,3:6:19-3:11:24",
"spread": true,
"pre": "",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-sibling-layer.d2,3:10:23-3:11:24",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
}
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-sibling-layer.d2,4:2:28-4:11:37",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-sibling-layer.d2,4:2:28-4:3:29",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-sibling-layer.d2,4:2:28-4:3:29",
"value": [
{
"string": "z",
"raw_string": "z"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-sibling-layer.d2,4:5:31-4:11:37",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-sibling-layer.d2,4:7:33-4:10:36",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-sibling-layer.d2,4:7:33-4:9:35",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-sibling-layer.d2,4:7:33-4:9:35",
"value": [
{
"string": "hi",
"raw_string": "hi"
}
]
}
}
]
},
"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": null,
"objects": [
{
"id": "k",
"id_val": "k",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-sibling-layer.d2,0:0:0-0:1:1",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-sibling-layer.d2,0:0:0-0:1:1",
"value": [
{
"string": "k",
"raw_string": "k"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "k"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
],
"layers": [
{
"name": "x",
"isFolderOnly": false,
"ast": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "a"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "link"
}
]
}
}
]
},
"primary": {
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "root.layers.x.layers.z"
}
]
}
},
"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": null,
"objects": [
{
"id": "a",
"id_val": "a",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/y.d2,0:0:0-0:6:6",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/y.d2,0:0:0-0:1:1",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/y.d2,0:2:2-0:6:6",
"value": [
{
"string": "link",
"raw_string": "link"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "a"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"link": {
"value": "root.layers.x.layers.z"
},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
]
},
{
"name": "z",
"isFolderOnly": false,
"ast": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "hi"
}
]
}
}
]
},
"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": null,
"objects": [
{
"id": "hi",
"id_val": "hi",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-sibling-layer.d2,4:7:33-4:9:35",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-link-sibling-layer.d2,4:7:33-4:9:35",
"value": [
{
"string": "hi",
"raw_string": "hi"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "hi"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
]
}
]
},
"err": null
}

View file

@ -3,8 +3,8 @@
"err": {
"errs": [
{
"range": "d2/testdata/d2compiler/TestCompile/link-board-underscore-not-found.d2,6:8:59-6:18:69",
"errmsg": "d2/testdata/d2compiler/TestCompile/link-board-underscore-not-found.d2:7:9: invalid underscore usage"
"range": "d2/testdata/d2compiler/TestCompile/link-board-underscore-not-found.d2,6:8:59-6:25:76",
"errmsg": "d2/testdata/d2compiler/TestCompile/link-board-underscore-not-found.d2:7:9: linked board not found"
}
]
}