check for the correct types when pruning values

There is not one more non-dependent type to look for when pruning unused
values. This fixes the oversight, but still leaves the ugly concrete
type checking which we need to remove.
This commit is contained in:
James Bardin 2020-04-02 12:47:16 -04:00
parent 2df7127943
commit c0bca9d5e9
1 changed files with 14 additions and 3 deletions

View File

@ -220,11 +220,22 @@ func (t *PruneUnusedValuesTransformer) Transform(g *Graph) error {
log.Printf("[TRACE] PruneUnusedValuesTransformer: removing unused value %s", dag.VertexName(v))
g.Remove(v)
removed++
case 1:
default:
// because an output's destroy node always depends on the output,
// we need to check for the case of a single destroy node.
d := dependants.List()[0]
if _, ok := d.(*NodeDestroyableOutput); ok {
removable := true
SEARCH:
for _, d := range dependants.List() {
switch d.(type) {
case *NodeDestroyableOutput, *nodeCloseModule:
//pass
default:
removable = false
break SEARCH
}
}
if removable {
log.Printf("[TRACE] PruneUnusedValuesTransformer: removing unused value %s", dag.VertexName(v))
g.Remove(v)
removed++