docs: Improve to_number built-in description (#8984)

The "strcov.Atoi" mention was both odd and incorrect. Hopefully a little
better now. Also a few other minor things.

Signed-off-by: Anders Eknert <anders.eknert@apple.com>
This commit is contained in:
Anders Eknert
2026-08-10 16:15:50 +02:00
committed by GitHub
parent ac4a791117
commit 0d9b9afa7d
4 changed files with 14 additions and 12 deletions
+4 -4
View File
@@ -22140,7 +22140,7 @@
"v1.19.0",
"edge"
],
"description": "Matches a string against a pattern, where there pattern may be glob-like",
"description": "Matches a string against a pattern, where the pattern may be glob-like",
"introduced": "v0.17.0",
"result": {
"description": "true if `value` matches the `template`",
@@ -26739,7 +26739,7 @@
"args": [
{
"description": "value to convert",
"name": "x",
"name": "value",
"type": "any\u003cnull, boolean, number, string\u003e"
}
],
@@ -26891,10 +26891,10 @@
"v1.19.0",
"edge"
],
"description": "Converts a string, bool, or number value to a number: Strings are converted to numbers using `strconv.Atoi`, Boolean `false` is converted to 0 and `true` is converted to 1.",
"description": "Converts value of type string, null or boolean to number. Numeric strings converts to the corresponding number when possible. Null and boolean `false` converts to 0 and boolean `true` to 1. Numbers are returned without conversion.",
"introduced": "v0.17.0",
"result": {
"description": "the numeric representation of `x`",
"description": "the numeric representation of `value`",
"name": "num",
"type": "number"
},
+7 -5
View File
@@ -941,18 +941,20 @@ var ArrayReverse = &Builtin{
var conversions = category("conversions")
var ToNumber = &Builtin{
Name: "to_number",
Description: "Converts a string, bool, or number value to a number: Strings are converted to numbers using `strconv.Atoi`, Boolean `false` is converted to 0 and `true` is converted to 1.",
Name: "to_number",
Description: "Converts value of type string, null or boolean to number. Numeric strings converts to the " +
"corresponding number when possible. Null and boolean `false` converts to 0 and boolean `true` to 1. " +
"Numbers are returned without conversion.",
Decl: types.NewFunction(
types.Args(
types.Named("x", types.NewAny(
types.Named("value", types.NewAny(
types.N,
types.S,
types.B,
types.Nl,
)).Description("value to convert"),
),
types.Named("num", types.N).Description("the numeric representation of `x`"),
types.Named("num", types.N).Description("the numeric representation of `value`"),
),
Categories: conversions,
CanSkipBctx: true,
@@ -1002,7 +1004,7 @@ var RegexFindAllStringSubmatch = &Builtin{
var RegexTemplateMatch = &Builtin{
Name: "regex.template_match",
Description: "Matches a string against a pattern, where there pattern may be glob-like",
Description: "Matches a string against a pattern, where the pattern may be glob-like",
Decl: types.NewFunction(
types.Args(
types.Named("template", types.S).Description("template expression containing `0..n` regular expressions"),
+2 -2
View File
@@ -528,7 +528,7 @@ func activateBundles(opts *ActivateOpts) error {
}
// Compile the modules all at once to avoid having to re-do work.
remainingAndExtra := make(map[string]*ast.Module)
remainingAndExtra := make(map[string]*ast.Module, len(remaining)+len(opts.ExtraModules))
maps.Copy(remainingAndExtra, remaining)
maps.Copy(remainingAndExtra, opts.ExtraModules)
@@ -994,7 +994,7 @@ func compileModules(compiler *ast.Compiler, m metrics.Metrics, bundles map[strin
return compiler.Errors
}
if authorizationDecisionRef.Equal(ast.EmptyRef()) {
if authorizationDecisionRef.Equal(ast.InternedEmptyRefValue) {
return nil
}
+1 -1
View File
@@ -5,5 +5,5 @@
// Package v1 implements the v1 API for the Open Policy Agent (OPA).
// The v1 API defaults to enforcing the v1 Rego syntax ([github.com/open-policy-agent/opa/v1/ast.RegoV1]).
// Most packages outside the v1 API are deprecated. These constitute the older v0 API, which defaults to the v0 Rego syntax ([github.com/open-policy-agent/opa/v1/ast.RegoV0]).
// The v0 API is provided as a means to ease transition to OPA 1.0 for 3rd party integrations, see [TODO: LINK TO V0 MIGRATION GUIDE].
// The v0 API is provided as a means to ease transition to OPA 1.0 for 3rd party integrations. For more information, see https://www.openpolicyagent.org/docs/v0-upgrade.
package v1