Rename addField to gatherField and reachMemo to renderCounts, and list every shared name left
This commit is contained in:
@@ -218,7 +218,7 @@ func checkScope(s nodeScope) error {
|
||||
// the walk. Its walks terminate only where nothing renders itself, so run it over a
|
||||
// loaded tree after checkNoCycles.
|
||||
func checkRenders(s nodeScope) error {
|
||||
mem := reachMemo{}
|
||||
mem := renderCounts{}
|
||||
if err := s(func(path string, n node) error { return repeatCheck(path, n, mem) }); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -169,9 +169,9 @@ func pathLeaves(n node, tail []string) []node {
|
||||
return out
|
||||
}
|
||||
|
||||
type reachMemo map[node]int
|
||||
type renderCounts map[node]int
|
||||
|
||||
func (m reachMemo) renderCount(n node) int {
|
||||
func (m renderCounts) renderCount(n node) int {
|
||||
if r, done := m[n]; done {
|
||||
return r
|
||||
}
|
||||
@@ -191,7 +191,7 @@ func (m reachMemo) renderCount(n node) int {
|
||||
// repeatCheck bounds the renders a repeat multiplies to along any root-to-leaf
|
||||
// path, so nested repeats cannot build what one repeat may not.
|
||||
// docs/decisions.md#the-repeat-cap-bounds-renders-not-bytes
|
||||
func repeatCheck(path string, n node, mem reachMemo) error {
|
||||
func repeatCheck(path string, n node, mem renderCounts) error {
|
||||
if t, ok := n.(*template); ok && t.repeat > 1 && mem.renderCount(n) > MaxRepeat {
|
||||
return fmt.Errorf("%s: repeat %d multiplies to %d renders along one path, above the maximum %d", path, t.repeat, mem.renderCount(n), MaxRepeat)
|
||||
}
|
||||
|
||||
@@ -123,19 +123,19 @@ func (sc *structCompile) spend(label string) error {
|
||||
return fmt.Errorf(`%s: the struct fields reach more than %d structs; leave a struct field unfilled with fake:"-"`, label, maxStructs)
|
||||
}
|
||||
|
||||
// gatherFields gathers the fields of struct type t, which sits at index within c.t.
|
||||
// t sits at index within c.t.
|
||||
func (c *structFields) gatherFields(t reflect.Type, index []int) error {
|
||||
for i := 0; i < t.NumField(); i++ {
|
||||
sf := t.Field(i)
|
||||
sf.Index = append(index[:len(index):len(index)], i)
|
||||
if err := c.addField(sf); err != nil {
|
||||
if err := c.gatherField(sf); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *structFields) addField(sf reflect.StructField) error {
|
||||
func (c *structFields) gatherField(sf reflect.StructField) error {
|
||||
tag, tagged := sf.Tag.Lookup("fake")
|
||||
elem := structOf(sf.Type)
|
||||
switch {
|
||||
|
||||
@@ -20,8 +20,9 @@ Self-sufficiency 5.6), every seat capped by Locality or Self-sufficiency.
|
||||
This round, in order:
|
||||
|
||||
- Rename the shared names left that name two things, per the decision "One name, one
|
||||
meaning": judge each of `check`, `draw`, `drawn`, `head`, `key`, `name`, `named`,
|
||||
`names`, `null`, `number`, `record` and `variant`.
|
||||
meaning": judge each of `check`, `children`, `column`, `columns`, `draw`, `drawn`,
|
||||
`fields`, `format`, `head`, `index`, `key`, `n`, `name`, `named`, `names`, `null`,
|
||||
`number`, `op`, `reads`, `record`, `root`, `row`, `t`, `variant` and `whole`.
|
||||
- Run the nine-seat panel again and file what it names here.
|
||||
|
||||
### Data
|
||||
|
||||
Reference in New Issue
Block a user