move edge check

This commit is contained in:
Alexander Wang 2023-07-13 14:34:33 -07:00
parent 29af92310b
commit f12f9ca69d
No known key found for this signature in database
GPG key ID: D89FA31966BDBECE
2 changed files with 9 additions and 5 deletions

View file

@ -278,11 +278,11 @@ func (c *compiler) compileField(obj *d2graph.Object, f *d2ir.Field) {
} }
return return
} else if f.Name == "vars" { } else if f.Name == "vars" {
if f.Map() != nil { // if f.Map() != nil {
if len(f.Map().Edges) > 0 { // if len(f.Map().Edges) > 0 {
c.errorf(f.Map().Edges[0].LastRef().AST(), "vars cannot contain an edge") // c.errorf(f.Map().Edges[0].LastRef().AST(), "vars cannot contain an edge")
} // }
} // }
return return
} else if isReserved { } else if isReserved {
c.compileReserved(&obj.Attributes, f) c.compileReserved(&obj.Attributes, f)

View file

@ -523,6 +523,10 @@ func (c *compiler) compileLink(refctx *RefContext) {
} }
func (c *compiler) compileEdges(refctx *RefContext) { func (c *compiler) compileEdges(refctx *RefContext) {
if IsVar(refctx.ScopeMap) {
c.errorf(refctx.Key, "vars cannot contain an edge")
return
}
if refctx.Key.Key != nil { if refctx.Key.Key != nil {
f, err := refctx.ScopeMap.EnsureField(refctx.Key.Key, refctx) f, err := refctx.ScopeMap.EnsureField(refctx.Key.Key, refctx)
if err != nil { if err != nil {