Skip to content

std.{any,all} fails with gibberish log when arr contains non boolean elements #1101

@ashi009

Description

@ashi009
std.all(["test"])

function expected 2 positional argument(s), but got 3

It turned out that std.formats are called with incorrect arguments.

jsonnet/stdlib/std.jsonnet

Lines 1648 to 1677 in 4d7a21c

all(arr)::
assert std.isArray(arr) : 'all() parameter should be an array, got ' + std.type(arr);
local arrLen = std.length(arr);
local aux(idx) =
if idx >= arrLen then
true
else
local e = arr[idx];
assert std.isBoolean(e) : std.format('element "%s" of type %s is not a boolean', e, std.type(e));
if !e then
false
else
aux(idx + 1) tailstrict;
aux(0),
any(arr)::
assert std.isArray(arr) : 'any() parameter should be an array, got ' + std.type(arr);
local arrLen = std.length(arr);
local aux(idx) =
if idx >= arrLen then
false
else
local e = arr[idx];
assert std.isBoolean(e) : std.format('element "%s" of type %s is not a boolean', e, std.type(e));
if e then
true
else
aux(idx + 1) tailstrict;
aux(0),

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions