fix: Align stdlib 1:1 edge semantics#800
Conversation
Motivation: Official Jsonnet std.jsonnet defines several edge-case stdlib behaviors that sjsonnet native implementations diverged from. The audit should keep hot paths native while making observable semantics match Jsonnet 0.22.0 where the behavior is clear and low risk. Modification: Add official-style comparison helpers, fix minArray/maxArray default sentinels and comparison errors, align mapWithIndex/flatten/removeAt/repeat/string escaping/isEmpty/resolvePath behavior, and preserve explicit keyF=false semantics in set helpers. Add directional compatibility coverage for the audited cases and update the existing isEmpty golden. Result: The new direction tests, full JVM test suite, format check, and whitespace check pass against this branch.
|
Additional audit update after adding source-built jrsonnet to the comparison matrix. Environment:
Summary:
Notable remaining/parallel items:
This PR can remain focused, but before final merge we should avoid a partial stdlib state where #800 lands without the earlier hidden-field/parse fixes or without clear follow-up issues for the deliberate policy differences. |
|
Follow-up from the expanded stdlib audit pass (100 additional function-family cases across official C++ Jsonnet 0.22.0, go-jsonnet 0.22.0, source-built jrsonnet New compatibility issues opened from that pass:
Already-covered differences observed in the same pass:
The broader pass did not change the assessment of this PR's core fixes: its included cases still match official behavior. The main integration concern remains merge/stack ordering so that #792/#794 and the follow-up issues are not lost from the overall stdlib alignment effort. |
Motivation
This follows a 1:1 stdlib audit against local
google/jsonnetstdlib/std.jsonnetand Jsonnet 0.22.0. Several native stdlib implementations in sjsonnet diverged on edge semantics while still needing to stay efficient on hot paths.Modification
minArray/maxArraydefault sentinels, explicitkeyF=false/onEmpty=false, and non-comparable value errors.mapWithIndex,flattenArrays,flattenDeepArray,repeat,removeAt,isEmpty, string escaping helpers, andresolvePath.keyF=falsebehavior in set helpers without treating it as the default sentinel.isEmptygolden.Result
git diff --check./mill --no-server 'sjsonnet.jvm[3.3.7].checkFormat'./mill --no-server 'sjsonnet.jvm[3.3.7].test'(141/141 passed)Follow-up Issues
Not mixed into this PR because they are higher-risk or need compatibility policy confirmation:
std.makeArrayfractional sizes.std.slicefractional index/step behavior.std.setUnionstring inputs.manifestIni/manifestTomlstrictness and formatting.Base64 non-ASCII and
substrfractional semantics remain tracked separately in #793 and #795.