fix: Align stdlib edge cases with Jsonnet#794
Open
He-Pin wants to merge 1 commit intodatabricks:masterfrom
Open
fix: Align stdlib edge cases with Jsonnet#794He-Pin wants to merge 1 commit intodatabricks:masterfrom
He-Pin wants to merge 1 commit intodatabricks:masterfrom
Conversation
Motivation: Several stdlib functions diverged from official Jsonnet on edge cases around lazy callbacks, ASCII-only string helpers, string set membership, parsing beyond Long range, and signed zero. Modification: Preserve lazy filterMap callback arguments, reject non-string string-flatMap results, implement ASCII-only case conversion and equalsIgnoreCase, allow string setMember validation, parse integers into Jsonnet number semantics, normalize std.sign(-0), and add directional tests validated against jsonnet v0.22.0. Result: sjsonnet matches official Jsonnet on these stdlib edge cases while avoiding unnecessary filterMap element evaluation and Unicode case-mapping overhead.
Contributor
Author
|
Additional audit note from the four-implementation matrix:
The PR #794 parse implementation appears to cover this because it routes parsing through if str[0] == '-' then
-parse_nat(str[1:], 10)
else
parse_nat(str, 10)So this is not a new issue if #794 lands, but it is worth keeping as an explicit direction test because go-jsonnet accepts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation:
Several stdlib functions diverged from official Jsonnet on lazy callback evaluation, ASCII-only string helpers, string set membership, numeric parsing beyond Long range, and signed zero handling.
Modification:
std.filterMapcallback laziness and avoid evaluating elements that the callbacks do not force.std.flatMapon strings, includingnull.std.asciiUpper,std.asciiLower, andstd.equalsIgnoreCaseASCII-only instead of JVM Unicode case folding.std.setMemberto operate on string sets with set validation enabled.std.parseInt,std.parseOctal, andstd.parseHexinto Jsonnet number semantics instead of Long-bounded integers.std.sign(-0)to numeric zero.new_test_suite.Result:
sjsonnet now matches official Jsonnet v0.22.0 for these stdlib edge cases while preserving performance-oriented implementations for hot paths.
Validation:
jsonnet --version->Jsonnet commandline interpreter v0.22.0jsonneton new success direction tests returnedtrue: filter_map_laziness, ascii_case_non_ascii, equals_ignore_case_ascii, set_member_string, parse_large_numbers, sign_negative_zero.jsonnetonerror.std.flatmap_string_null.jsonneterrors withstd.flatMap on strings, provided function must return a string, got null../mill --no-server sjsonnet.jvm[3.3.7].test-> SUCCESS./mill --no-server sjsonnet.jvm[3.3.7].checkFormat-> SUCCESSgit diff --checkandgit diff --cached --check-> cleanNotes: