fix: cr, error info

This commit is contained in:
donglixiaoche 2023-03-30 18:15:11 +08:00
parent b9dd247c75
commit 6ee58d756e
No known key found for this signature in database
GPG key ID: 3190E65EBAD6D6E2

View file

@ -736,19 +736,19 @@ func (c *compiler) validateNear(g *d2graph.Graph) {
continue
}
connectToOutside := false
var edgeConnectToOutsideOfNear *d2graph.Edge
for _, edge := range g.Edges {
srcNearContainer := edge.Src.OuterNearContainer()
dstNearContainer := edge.Dst.OuterNearContainer()
if srcNearContainer != dstNearContainer {
connectToOutside = true
edgeConnectToOutsideOfNear = edge
break
}
}
if connectToOutside {
c.errorf(obj.Attributes.NearKey, "a child of a near container cannot connect to outside")
if edgeConnectToOutsideOfNear != nil {
c.errorf(edgeConnectToOutsideOfNear.References[0].Edge, "cannot connect objects from within a container, that has near constant set, to objects outside that container")
continue
}
} else {