From 8793681d8abae0b142d1f050ea069cdac5974291 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 29 Sep 2026 12:13:33 +0200 Subject: [PATCH] Test a table cell through tableSite.isCell, and trace no row outside a table --- hold.go | 2 +- node.go | 4 ++++ readsurvey.go | 6 +++--- reference.go | 2 +- render.go | 15 +++++++-------- todo.md | 2 -- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/hold.go b/hold.go index dfaf116..e63e517 100644 --- a/hold.go +++ b/hold.go @@ -24,7 +24,7 @@ type readValue struct { } // renderTrace is a test's view of the fields a render reads; nil outside a test. -type renderTrace func(group, table string, row int, a arm) +type renderTrace func(group string, row renderedRow, a arm) // holdSet is one render's reference draws: the unnamed draw group's, and each named one's; and a // test's trace of its reads. diff --git a/node.go b/node.go index 03542a1..c10069b 100644 --- a/node.go +++ b/node.go @@ -71,6 +71,10 @@ type tableSite struct { const formatRow = -1 +func (s tableSite) isCell() bool { + return s.table != nil && s.row != formatRow +} + // templateLink is what a template resolves to in the assembled tree. type templateLink struct { refs map[string]refBinding // each reference the format reads -> what it resolves to diff --git a/readsurvey.go b/readsurvey.go index e08dba1..531e8c7 100644 --- a/readsurvey.go +++ b/readsurvey.go @@ -88,12 +88,12 @@ func (s *readSurvey) walk(n node, at surveyAt) { } for _, e := range renderEdges(n) { to, isTemplate := e.to.(*template) - cell := tableSite{} - if isTemplate && to.site.row != formatRow { + var cell tableSite + if isTemplate { cell = to.site } switch { - case cell.table == nil: + case !cell.isCell(): s.edge(n, e, at) case cell.table == at.wholeTable: in := at diff --git a/reference.go b/reference.go index 62c477c..861104e 100644 --- a/reference.go +++ b/reference.go @@ -81,7 +81,7 @@ func linkRefs(root map[string]node) error { // linkTemplate resolves t's references in category, "" for an inline template, and // compiles its format against them. func linkTemplate(folder []string, path, category string, t *template, root map[string]node) error { - if t.site.table != nil && t.site.row != formatRow { + if t.site.isCell() { path = fmt.Sprintf("%s, line %d", path, t.site.row+2) } link, err := t.resolveLink(folder, path, category, root) diff --git a/render.go b/render.go index ce34353..2c5d8db 100644 --- a/render.go +++ b/render.go @@ -203,15 +203,14 @@ func readHeld(s *session, t *template, held *hold, pins *pinSet, sc renderScope, } func traceRead(trace renderTrace, t *template, sc renderScope, a arm) { - var table string - row := t.site.row - if t.site.table != nil { - table = t.site.table.path + var row renderedRow + switch { + case t.site.isCell(): + row = renderedRow{t.site.table, t.site.row} + case t.site.table != nil: + row = renderedRow{t.site.table, sc.rowOf(t.site.table)} } - if row == formatRow { - row = sc.rowOf(t.site.table) - } - trace(strings.Clone(sc.group), strings.Clone(table), row, a) + trace(strings.Clone(sc.group), row, a) } // renderLeaf draws and renders what a read lands on: null on a null item, or on a column of one diff --git a/todo.md b/todo.md index 84fa028..5215fb9 100644 --- a/todo.md +++ b/todo.md @@ -31,8 +31,6 @@ on 2026-09-29 a third time (Navigation 7.0, Locality 5.6, Shape 6.3, Self-suffic This round, in order: -- Give `tableSite` one test for a cell, and have `traceRead` report no row outside a - table: the zero value reads as row 0, a real cell, so each reader tests `table` first. - Rename `ftoken` to `scanUnit`, beside `formatToken`, and `session` to `generatorState`: three seats confused the token types, and both architects read `session` as per-render state.