From 97488fe2d8530b4b07791070c8625eb5ff41bee1 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Thu, 28 Sep 2023 18:08:49 -0700 Subject: [PATCH] updating validation --- d2compiler/compile.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/d2compiler/compile.go b/d2compiler/compile.go index b359d57be..87a111105 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -1081,7 +1081,7 @@ func (c *compiler) validateNear(g *d2graph.Graph) { } 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") + // c.errorf(edge.References[0].Edge, "cannot connect objects from within a container, that has near constant set, to objects outside that container") } } @@ -1101,6 +1101,14 @@ func (c *compiler) validateEdges(g *d2graph.Graph) { c.errorf(edge.GetAstEdge(), "edge from grid diagram %#v cannot enter itself", edge.Dst.AbsID()) continue } + if edge.Src.Parent.IsGridDiagram() && edge.Dst.IsDescendantOf(edge.Src) { + c.errorf(edge.GetAstEdge(), "edge from grid cell %#v cannot enter itself", edge.Src.AbsID()) + continue + } + if edge.Dst.Parent.IsGridDiagram() && edge.Src.IsDescendantOf(edge.Dst) { + 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()