You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Discovered the following behavior difference between sjsonnet and jsonnet.
test.jsonnet:
// Returns true if any key from base is overridden in object
local isAnyKeyOverridden = function (base, object)
local keys = std.objectFields(base);
std.foldl(function(acc, field) acc || base[field] != object[field], keys, false);
local base = {
paramA: null,
paramB: null,
};
base + {
assert !isAnyKeyOverridden(base, $),
}
test2.jsonnet:
local base = import "test.jsonnet";
local Parameterized = base + { paramA:: 3 };
Parameterized
Output from jsonnet test2.jsonnet:
RUNTIME ERROR: Object assertion failed.
../universe/test.jsonnet:12:10-38 thunk <object_assert>
During manifestation
Output from sjsonnet test2.jsonnet:
{
"paramB": null
}
The text was updated successfully, but these errors were encountered:
I think I have also run into this bug, and I have found a simpler reproducer:
{ } + {
assert false
}
With jsonnet this fails, with sjsonnet it just returns { }.
Apparently, when combining objects, it's ignoring assertions from the second object. Putting the assertion in the first object makes it fail as expected.
In the original bug report, if you switch the + around, it also fails as expected:
Discovered the following behavior difference between sjsonnet and jsonnet.
test.jsonnet:
test2.jsonnet:
Output from
jsonnet test2.jsonnet
:Output from
sjsonnet test2.jsonnet
:The text was updated successfully, but these errors were encountered: