Pin the builtin registry shape and grow as a lower bound, and correct stale comments

This commit is contained in:
Mikael Göransson
2026-08-27 23:48:35 +02:00
committed by lilleman-tw
parent ab9846c2ff
commit 37759f773f
6 changed files with 71 additions and 22 deletions
+17
View File
@@ -181,3 +181,20 @@ func ibanValid(s string) bool {
}
return rem == 1
}
// TestRegistryShapes pins the builtin contract bind relies on: exactly one of prep
// or call, and args parsed at compile only behind a check. A registry entry with
// neither would compile and then panic inside a render.
func TestRegistryShapes(t *testing.T) {
for name, b := range builtins {
switch {
case b.prep == nil && b.call == nil:
t.Errorf("builtin %q has neither prep nor call: bind would return a nil-func closure", name)
case b.prep != nil && b.call != nil:
t.Errorf("builtin %q has both prep and call; call is dead", name)
}
if b.prep != nil && b.arity != 0 && b.check == nil {
t.Errorf("builtin %q parses args in prep with no check", name)
}
}
}