Refuse a calc over digits(0) or a repeat of 0, name an option's wrong kind as JSON does, type the name scope kinds, and compile only from a jsonvalue.Value

This commit is contained in:
2026-10-08 00:02:07 +02:00
committed by Lillem4n
parent ba2ae41ffe
commit 97e72988b1
13 changed files with 106 additions and 55 deletions
+3
View File
@@ -36,6 +36,9 @@ var builtins = withTransforms(map[string]builtin{
"nanoid": {arity: 1, checkArgs: countArg, prep: chars(nanoidAlphabet)},
"hex": {arity: 1, checkArgs: countArg, prep: chars(hexDigits)},
"digits": {arity: 1, checkArgs: countArg, prep: chars("0123456789"), prints: datatype.String, proveNumber: func(token string, prints datatype.DataType, a []string) proven.Facts {
if atoi(a[0]) == 0 {
return proven.Unproven("{" + token + "} prints nothing, which is no number")
}
return proven.Printing(token, prints, proven.Bounded(0, math.Pow(10, float64(atoi(a[0])))-1, true))
}},
"upper": {arity: 1, checkArgs: countArg, prep: chars("ABCDEFGHIJKLMNOPQRSTUVWXYZ")},