depgraph: detect loops to yourself

This commit is contained in:
Mitchell Hashimoto 2014-07-24 07:43:23 -07:00
parent f82b0552e0
commit 945f41d192
1 changed files with 9 additions and 0 deletions

View File

@ -232,6 +232,15 @@ CHECK_CYCLES:
} }
} }
// Check for loops to yourself
for _, n := range g.Nouns {
for _, d := range n.Deps {
if d.Source == d.Target {
vErr.Cycles = append(vErr.Cycles, []*Noun{n})
}
}
}
// Return the detailed error // Return the detailed error
if vErr.MissingRoot || vErr.Unreachable != nil || vErr.Cycles != nil { if vErr.MissingRoot || vErr.Unreachable != nil || vErr.Cycles != nil {
return vErr return vErr