Report every invariant break through internalError

This commit is contained in:
2026-09-29 01:38:45 +02:00
committed by Lillem4n
parent 3aa747de02
commit 514d738b08
13 changed files with 25 additions and 27 deletions
+3 -3
View File
@@ -38,7 +38,7 @@ func (n calcIdx) eval(operands []string) float64 {
// than returning NaN, so a node kind indexVars forgets is a stack trace and not a
// silently wrong number.
func (n calcVar) eval([]string) float64 {
panic(fmt.Sprintf("fejkdata: calc operand %q was never placed", string(n)))
panic(internalError("calc operand %q was never placed", string(n)))
}
func (n calcNeg) eval(operands []string) float64 { return -n.x.eval(operands) }
@@ -191,7 +191,7 @@ func neverNumeric(n node) (text string, never bool) {
func calcPrep(args []string) callFn {
expr, err := parseCalc(args[0])
if err != nil { // a nil AST would be a nil dereference per render, with no message
panic(fmt.Sprintf("fejkdata: calc(%q) reached prep unparsed: %v", args[0], err))
panic(internalError("calc(%q) reached prep unparsed: %v", args[0], err))
}
at := make(map[string]int)
for i, name := range calcVars(expr) {
@@ -219,7 +219,7 @@ func indexVars(n calcNode, at map[string]int) calcNode {
case calcVar:
i, placed := at[string(n)]
if !placed { // calcVars named every operand, so a miss means the two disagree
panic(fmt.Sprintf("fejkdata: calc operand %q is not among the names read for it", string(n)))
panic(internalError("calc operand %q is not among the names read for it", string(n)))
}
return calcIdx(i)
case calcNeg: