Panic through internalError on a node kind contained or paths does not list
This commit is contained in:
+2
-1
@@ -161,8 +161,9 @@ func paths(n node) []string {
|
||||
out = append(out, p)
|
||||
}
|
||||
return out
|
||||
default:
|
||||
panic(internalError("paths has no case for node %T", n))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// tablePaths is a table's columns, then each table linked to it under its name: the
|
||||
|
||||
@@ -73,8 +73,10 @@ func contained(n node) []namedNode {
|
||||
}
|
||||
}
|
||||
return out
|
||||
default:
|
||||
case *nullItem, *tableRow:
|
||||
return nil
|
||||
default:
|
||||
panic(internalError("contained has no case for node %T", n))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,8 @@ func descend(s *session, root node, segments []string, sc renderScope) (node, er
|
||||
// render evaluates a compiled node to a string. compile validates every node up
|
||||
// front, so rendering a compiled tree cannot fail. sc holds the reference draws the
|
||||
// render shares; each repeat iteration renders over a hold set of its own.
|
||||
// renderEdges mirrors this switch for the fences, so a new node kind goes in both.
|
||||
// renderEdges mirrors this switch for the fences. A new node kind goes in every switch
|
||||
// that panics through internalError on a kind it does not list.
|
||||
func render(s *session, n node, sc renderScope) string {
|
||||
switch n := n.(type) {
|
||||
case *choice:
|
||||
|
||||
@@ -26,10 +26,6 @@ least modify.
|
||||
|
||||
This round, in order:
|
||||
|
||||
- Make every switch over node kinds panic through `internalError` on a kind it does not
|
||||
list, as `render` and `renderEdges` do, naming the kinds it skips: `contained` and
|
||||
`paths` return nil. Correct `render`'s "a new node kind goes in both", which misses
|
||||
the rest.
|
||||
- Rename the load-time `draw*` types (`drawWalk`, `drawAt`, `drawRoute`, `drawCheck`)
|
||||
to say they read and draw nothing, and move `drawWalk` and `tableRead` out of
|
||||
`drawfence.go`: a grep for "draw" lands in render and check code alike.
|
||||
|
||||
Reference in New Issue
Block a user