cleanup validation

This commit is contained in:
Gavin Nishizawa 2023-09-28 19:57:34 -07:00
parent b41a9e4e96
commit 2a9acd06aa
No known key found for this signature in database
GPG key ID: AE3B177777CE55CD
8 changed files with 1128 additions and 118 deletions

View file

@ -1068,21 +1068,6 @@ func (c *compiler) validateNear(g *d2graph.Graph) {
}
for _, edge := range g.Edges {
srcNearContainer := edge.Src.OuterNearContainer()
dstNearContainer := edge.Dst.OuterNearContainer()
var isSrcNearConst, isDstNearConst bool
if srcNearContainer != nil {
_, isSrcNearConst = d2graph.NearConstants[d2graph.Key(srcNearContainer.NearKey)[0]]
}
if dstNearContainer != nil {
_, isDstNearConst = d2graph.NearConstants[d2graph.Key(dstNearContainer.NearKey)[0]]
}
if (isSrcNearConst || isDstNearConst) && srcNearContainer != dstNearContainer {
// c.errorf(edge.References[0].Edge, "cannot connect objects from within a container, that has near constant set, to objects outside that container")
}
if edge.Src.IsConstantNear() && edge.Dst.IsDescendantOf(edge.Src) {
c.errorf(edge.GetAstEdge(), "edge from constant near %#v cannot enter itself", edge.Src.AbsID())
continue
@ -1117,47 +1102,6 @@ func (c *compiler) validateEdges(g *d2graph.Graph) {
c.errorf(edge.GetAstEdge(), "edge from grid cell %#v cannot enter itself", edge.Dst.AbsID())
continue
}
srcGrid := edge.Src.Parent.ClosestGridDiagram()
dstGrid := edge.Dst.Parent.ClosestGridDiagram()
if srcGrid != nil || dstGrid != nil {
if srcGrid != dstGrid {
// valid: a -> grid
// invalid: a -> grid.child
// if dstGrid != nil && !(srcGrid != nil && srcGrid.IsDescendantOf(dstGrid)) {
// c.errorf(edge.GetAstEdge(), "edge cannot enter grid diagram %#v", dstGrid.AbsID())
// } else {
// c.errorf(edge.GetAstEdge(), "edge cannot exit grid diagram %#v", srcGrid.AbsID())
// }
continue
}
srcCell := edge.Src.ClosestGridCell()
dstCell := edge.Dst.ClosestGridCell()
// edges within a grid cell are ok now
// grid.cell.a -> grid.cell.b : ok
// grid.cell.a.c -> grid.cell.b.d : ok
// edges between grid cells themselves are ok
// grid.cell -> grid.cell2 : ok
// grid.cell -> grid.cell.inside : not ok
// grid.cell -> grid.cell2.inside : not ok
srcIsGridCell := edge.Src == srcCell
dstIsGridCell := edge.Dst == dstCell
if srcIsGridCell != dstIsGridCell {
// if srcIsGridCell {
// c.errorf(edge.GetAstEdge(), "grid cell %#v can only connect to another grid cell", edge.Src.AbsID())
// } else {
// c.errorf(edge.GetAstEdge(), "grid cell %#v can only connect to another grid cell", edge.Dst.AbsID())
// }
// continue
}
if srcCell != dstCell && (!srcIsGridCell || !dstIsGridCell) {
// c.errorf(edge.GetAstEdge(), "edge cannot exit grid cell %#v", srcCell.AbsID())
// continue
}
}
}
}

View file

@ -1616,7 +1616,7 @@ d2/testdata/d2compiler/TestCompile/near-invalid.d2:14:9: near keys cannot be set
}
x -> y
`,
expErr: `d2/testdata/d2compiler/TestCompile/near_bad_connected.d2:5:5: cannot connect objects from within a container, that has near constant set, to objects outside that container`,
expErr: ``,
},
{
name: "near_descendant_connect_to_outside",
@ -1627,7 +1627,7 @@ d2/testdata/d2compiler/TestCompile/near-invalid.d2:14:9: near keys cannot be set
}
x.y -> z
`,
expErr: "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2:6:5: cannot connect objects from within a container, that has near constant set, to objects outside that container",
expErr: "",
},
{
name: "nested_near_constant",
@ -2040,7 +2040,7 @@ b
}
b -> x.a
`,
expErr: `d2/testdata/d2compiler/TestCompile/leaky_sequence.d2:5:1: connections within sequence diagrams can connect only to other objects within the same sequence diagram`,
expErr: ``,
},
{
name: "sequence_scoping",
@ -2484,9 +2484,7 @@ hey -> hey.a
hey -> c: ok
`,
expErr: `d2/testdata/d2compiler/TestCompile/grid_edge.d2:5:1: edge cannot enter grid diagram "hey"
d2/testdata/d2compiler/TestCompile/grid_edge.d2:6:1: edge cannot exit grid diagram "hey"
d2/testdata/d2compiler/TestCompile/grid_edge.d2:7:1: edge from grid diagram "hey" cannot enter itself`,
expErr: `d2/testdata/d2compiler/TestCompile/grid_edge.d2:7:1: edge from grid diagram "hey" cannot enter itself`,
},
{
name: "grid_deeper_edge",
@ -2506,19 +2504,15 @@ d2/testdata/d2compiler/TestCompile/grid_edge.d2:7:1: edge from grid diagram "hey
g -> h: ok
g -> h.h: ok
}
e -> f.i: not ok
e.g -> f.i: not ok
e -> f.i: ok now
e.g -> f.i: ok now
}
a -> b.c: not yet
a.e -> b.c: also not yet
a -> b.c: ok now
a.e -> b.c: ok now
a -> a.e: not ok
}
`,
expErr: `d2/testdata/d2compiler/TestCompile/grid_deeper_edge.d2:17:3: grid cell "hey.a.e" can only connect to another grid cell
d2/testdata/d2compiler/TestCompile/grid_deeper_edge.d2:18:3: edge cannot exit grid cell "hey.a.e"
d2/testdata/d2compiler/TestCompile/grid_deeper_edge.d2:20:2: grid cell "hey.a" can only connect to another grid cell
d2/testdata/d2compiler/TestCompile/grid_deeper_edge.d2:21:2: edge cannot exit grid diagram "hey.a"
d2/testdata/d2compiler/TestCompile/grid_deeper_edge.d2:22:2: edge from grid diagram "hey.a" cannot enter itself`,
expErr: `d2/testdata/d2compiler/TestCompile/grid_deeper_edge.d2:22:2: edge from grid diagram "hey.a" cannot enter itself`,
},
{
name: "grid_nested",

View file

@ -1225,10 +1225,6 @@ func (obj *Object) Connect(srcID, dstID []string, srcArrow, dstArrow bool, label
src := obj.ensureChildEdge(srcID)
dst := obj.ensureChildEdge(dstID)
if src.OuterSequenceDiagram() != dst.OuterSequenceDiagram() {
// return nil, errors.New("connections within sequence diagrams can connect only to other objects within the same sequence diagram")
}
e := &Edge{
Attributes: Attributes{
Label: Scalar{

View file

@ -3,23 +3,7 @@
"err": {
"errs": [
{
"range": "d2/testdata/d2compiler/TestCompile/grid_deeper_edge.d2,16:2:199-16:10:207",
"errmsg": "d2/testdata/d2compiler/TestCompile/grid_deeper_edge.d2:17:3: grid cell \"hey.a.e\" can only connect to another grid cell"
},
{
"range": "d2/testdata/d2compiler/TestCompile/grid_deeper_edge.d2,17:2:218-17:12:228",
"errmsg": "d2/testdata/d2compiler/TestCompile/grid_deeper_edge.d2:18:3: edge cannot exit grid cell \"hey.a.e\""
},
{
"range": "d2/testdata/d2compiler/TestCompile/grid_deeper_edge.d2,19:1:241-19:9:249",
"errmsg": "d2/testdata/d2compiler/TestCompile/grid_deeper_edge.d2:20:2: grid cell \"hey.a\" can only connect to another grid cell"
},
{
"range": "d2/testdata/d2compiler/TestCompile/grid_deeper_edge.d2,20:1:260-20:11:270",
"errmsg": "d2/testdata/d2compiler/TestCompile/grid_deeper_edge.d2:21:2: edge cannot exit grid diagram \"hey.a\""
},
{
"range": "d2/testdata/d2compiler/TestCompile/grid_deeper_edge.d2,21:1:286-21:9:294",
"range": "d2/testdata/d2compiler/TestCompile/grid_deeper_edge.d2,21:1:279-21:9:287",
"errmsg": "d2/testdata/d2compiler/TestCompile/grid_deeper_edge.d2:22:2: edge from grid diagram \"hey.a\" cannot enter itself"
}
]

View file

@ -2,14 +2,6 @@
"graph": null,
"err": {
"errs": [
{
"range": "d2/testdata/d2compiler/TestCompile/grid_edge.d2,4:0:35-4:10:45",
"errmsg": "d2/testdata/d2compiler/TestCompile/grid_edge.d2:5:1: edge cannot enter grid diagram \"hey\""
},
{
"range": "d2/testdata/d2compiler/TestCompile/grid_edge.d2,5:0:46-5:10:56",
"errmsg": "d2/testdata/d2compiler/TestCompile/grid_edge.d2:6:1: edge cannot exit grid diagram \"hey\""
},
{
"range": "d2/testdata/d2compiler/TestCompile/grid_edge.d2,6:0:57-6:12:69",
"errmsg": "d2/testdata/d2compiler/TestCompile/grid_edge.d2:7:1: edge from grid diagram \"hey\" cannot enter itself"

View file

@ -1,11 +1,408 @@
{
"graph": null,
"err": {
"errs": [
"graph": {
"name": "",
"isFolderOnly": false,
"ast": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,0:0:0-5:0:46",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,0:0:0-3:1:36",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,0:0:0-0:1:1",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,0:0:0-0:1:1",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,0:3:3-3:1:36",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,1:2:7-1:25:30",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,1:2:7-1:7:12",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,1:2:7-1:7:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,1:9:14-1:25:30",
"value": [
{
"string": "sequence_diagram",
"raw_string": "sequence_diagram"
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,2:2:33-2:3:34",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,2:2:33-2:3:34",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,2:2:33-2:3:34",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
}
]
},
"primary": {},
"value": {}
}
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,4:0:37-4:8:45",
"edges": [
{
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,4:0:37-4:8:45",
"src": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,4:0:37-4:1:38",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,4:0:37-4:1:38",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"src_arrow": "",
"dst": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,4:5:42-4:8:45",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,4:5:42-4:6:43",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,4:7:44-4:8:45",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
}
]
},
"dst_arrow": ">"
}
],
"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": [
{
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,4:0:37-4:8:45",
"errmsg": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2:5:1: connections within sequence diagrams can connect only to other objects within the same sequence diagram"
"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": "x",
"id_val": "x",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,0:0:0-0:1:1",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,0:0:0-0:1:1",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
},
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,4:5:42-4:8:45",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,4:5:42-4:6:43",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,4:7:44-4:8:45",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "x"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": "sequence_diagram"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
},
{
"id": "a",
"id_val": "a",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,2:2:33-2:3:34",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,2:2:33-2:3:34",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
},
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,4:5:42-4:8:45",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,4:5:42-4:6:43",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,4:7:44-4:8:45",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
}
]
},
"key_path_index": 1,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "a"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
},
{
"id": "b",
"id_val": "b",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,4:0:37-4:1:38",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/leaky_sequence.d2,4:0:37-4:1:38",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "b"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
]
}
},
"err": null
}

View file

@ -1,11 +1,302 @@
{
"graph": null,
"err": {
"errs": [
"graph": {
"name": "",
"isFolderOnly": false,
"ast": {
"range": "d2/testdata/d2compiler/TestCompile/near_bad_connected.d2,0:0:0-5:3:52",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/near_bad_connected.d2,1:4:5-3:5:37",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/near_bad_connected.d2,1:4:5-1:5:6",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/near_bad_connected.d2,1:4:5-1:5:6",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile/near_bad_connected.d2,1:7:8-3:5:37",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/near_bad_connected.d2,2:5:15-2:21:31",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/near_bad_connected.d2,2:5:15-2:9:19",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/near_bad_connected.d2,2:5:15-2:9:19",
"value": [
{
"string": "near",
"raw_string": "near"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/near_bad_connected.d2,2:11:21-2:21:31",
"value": [
{
"string": "top-center",
"raw_string": "top-center"
}
]
}
}
}
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/near_bad_connected.d2,4:4:42-4:10:48",
"edges": [
{
"range": "d2/testdata/d2compiler/TestCompile/near_bad_connected.d2,4:4:42-4:10:48",
"src": {
"range": "d2/testdata/d2compiler/TestCompile/near_bad_connected.d2,4:4:42-4:5:43",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/near_bad_connected.d2,4:4:42-4:5:43",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"src_arrow": "",
"dst": {
"range": "d2/testdata/d2compiler/TestCompile/near_bad_connected.d2,4:9:47-4:10:48",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/near_bad_connected.d2,4:9:47-4:10:48",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"dst_arrow": ">"
}
],
"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": [
{
"range": "d2/testdata/d2compiler/TestCompile/near_bad_connected.d2,4:4:42-4:10:48",
"errmsg": "d2/testdata/d2compiler/TestCompile/near_bad_connected.d2:5:5: cannot connect objects from within a container, that has near constant set, to objects outside that container"
"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": "x",
"id_val": "x",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/near_bad_connected.d2,1:4:5-1:5:6",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/near_bad_connected.d2,1:4:5-1:5:6",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
},
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/near_bad_connected.d2,4:4:42-4:5:43",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/near_bad_connected.d2,4:4:42-4:5:43",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "x"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": {
"range": "d2/testdata/d2compiler/TestCompile/near_bad_connected.d2,2:11:21-2:21:31",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:10:10",
"value": [
{
"string": "top-center",
"raw_string": "top-center"
}
]
}
}
]
},
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
},
{
"id": "y",
"id_val": "y",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/near_bad_connected.d2,4:9:47-4:10:48",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/near_bad_connected.d2,4:9:47-4:10:48",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "y"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
]
}
},
"err": null
}

View file

@ -1,11 +1,423 @@
{
"graph": null,
"err": {
"errs": [
"graph": {
"name": "",
"isFolderOnly": false,
"ast": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,0:0:0-6:3:59",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,1:4:5-4:5:42",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,1:4:5-1:5:6",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,1:4:5-1:5:6",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,1:7:8-4:5:42",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,2:5:15-2:19:29",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,2:5:15-2:9:19",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,2:5:15-2:9:19",
"value": [
{
"string": "near",
"raw_string": "near"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,2:11:21-2:19:29",
"value": [
{
"string": "top-left",
"raw_string": "top-left"
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,3:5:35-3:6:36",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,3:5:35-3:6:36",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,3:5:35-3:6:36",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"primary": {},
"value": {}
}
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,5:4:47-5:12:55",
"edges": [
{
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,5:4:47-5:12:55",
"src": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,5:4:47-5:7:50",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,5:4:47-5:5:48",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,5:6:49-5:7:50",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"src_arrow": "",
"dst": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,5:11:54-5:12:55",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,5:11:54-5:12:55",
"value": [
{
"string": "z",
"raw_string": "z"
}
]
}
}
]
},
"dst_arrow": ">"
}
],
"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": [
{
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,5:4:47-5:12:55",
"errmsg": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2:6:5: cannot connect objects from within a container, that has near constant set, to objects outside that container"
"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": "x",
"id_val": "x",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,1:4:5-1:5:6",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,1:4:5-1:5:6",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
},
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,5:4:47-5:7:50",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,5:4:47-5:5:48",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,5:6:49-5:7:50",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "x"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,2:11:21-2:19:29",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:8:8",
"value": [
{
"string": "top-left",
"raw_string": "top-left"
}
]
}
}
]
},
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
},
{
"id": "y",
"id_val": "y",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,3:5:35-3:6:36",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,3:5:35-3:6:36",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
},
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,5:4:47-5:7:50",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,5:4:47-5:5:48",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,5:6:49-5:7:50",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"key_path_index": 1,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "y"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
},
{
"id": "z",
"id_val": "z",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,5:11:54-5:12:55",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/near_descendant_connect_to_outside.d2,5:11:54-5:12:55",
"value": [
{
"string": "z",
"raw_string": "z"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "z"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
]
}
},
"err": null
}