diff --git a/fejkdata.go b/fejkdata.go index 73d54ab..21a75cc 100644 --- a/fejkdata.go +++ b/fejkdata.go @@ -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 diff --git a/graph.go b/graph.go index 20e5b74..fee1b54 100644 --- a/graph.go +++ b/graph.go @@ -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)) } } diff --git a/render.go b/render.go index 3b864ff..90e9827 100644 --- a/render.go +++ b/render.go @@ -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: diff --git a/todo.md b/todo.md index dc7f8de..ddab1d6 100644 --- a/todo.md +++ b/todo.md @@ -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.