Support non-finite floats in exit test captures - #1837
Conversation
grynspan
left a comment
There was a problem hiding this comment.
Thanks for the PR! And thank you for not making the change everywhere we encode/decode JSON (as that would be an ABI break for our JSON event stream and would require Swift Evolution approval).
I am hesitant to approve the change without a better understanding of how unreal values are handled in other systems that use JSON. It would help if you could gather some examples of what other languages, libraries, implementations, etc. are currently doing to handle them.
We are unlikely to take further changes to Swift 6.4.0 at this point in the schedule, however once this PR is merged you can open a new PR targetting I am not aware of any future planned updates to Swift 6.3. The bar for changes there is exceptionally high. |
stmontgomery
left a comment
There was a problem hiding this comment.
Aside from @grynspan's remaining style comment, this looks good to me now, thank you!
9b7567b to
9b1b1d2
Compare
9b1b1d2 to
16037ea
Compare
|
@grynspan The style issue is fixed. Any other suggestion? |
|
Thanks! |
Allow exit test capture lists to round-trip NaN and positive and negative infinity.
Motivation:
Exit-test value capturing became available in Swift 6.3. Captured values are JSON-encoded in the parent process and decoded in the subprocess. The default JSON coding strategies reject non-finite floating-point values even though
FloatandDoublesatisfy theCodableandSendablerequirements for captured values.Fixes #1836.
Modifications:
Configure matching non-conforming floating-point encoding and decoding strategies specifically for the exit-test captured-value transport, using an internal coding user-info key so other JSON call sites retain their default behavior.
Use
"NaN","Infinity", and"-Infinity"as the JSON string representations, following conventions used by other JSON encoders.Add a parameterized regression test covering positive infinity, negative infinity, and NaN, including validation that their classification and sign survive the round trip.
AI Disclosure:
Codex was used to help investigate the exit-test capture path, research JSON prior art, and draft and refine the implementation, tests, and PR text. I reviewed the resulting changes and verified the regression test locally.
Checklist:
Future discussion
I suggest this should also be cherry-picked into release/6.4 and release/6.3.