Skip to content

Support non-finite floats in exit test captures - #1837

Merged
grynspan merged 3 commits into
swiftlang:mainfrom
Kyle-Ye:bugfix/fix-exit-test-non-finite-floats
Aug 18, 2026
Merged

Support non-finite floats in exit test captures#1837
grynspan merged 3 commits into
swiftlang:mainfrom
Kyle-Ye:bugfix/fix-exit-test-non-finite-floats

Conversation

@Kyle-Ye

@Kyle-Ye Kyle-Ye commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

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 Float and Double satisfy the Codable and Sendable requirements 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:

  • Code and documentation follow the style of the Style Guide.
  • No public symbols are renamed or modified, so no DocC references need updating.

Future discussion

I suggest this should also be cherry-picked into release/6.4 and release/6.3.

@grynspan grynspan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread Sources/Testing/Support/JSON.swift Outdated
Comment thread Sources/Testing/Support/JSON.swift Outdated
Comment thread Tests/TestingTests/ExitTestTests.swift
@grynspan

Copy link
Copy Markdown
Contributor

I suggest this should also be cherry-picked into release/6.4 and release/6.3.

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 release/6.4.x and we can see if it meets the criteria for 6.4.1 (or whatever dot release we're on at that point).

I am not aware of any future planned updates to Swift 6.3. The bar for changes there is exceptionally high.

@grynspan grynspan added enhancement New feature or request exit-tests ☠️ Work related to exit tests exit-test-capture-lists 🥍 Work related to exit test capture lists labels Aug 17, 2026
@grynspan grynspan added this to the Swift 6.5.0 (main) milestone Aug 17, 2026
@Kyle-Ye
Kyle-Ye requested a review from grynspan August 17, 2026 15:23
@grynspan grynspan added the ai-assisted 🤖 This issue or pull request was created (in whole or in part) by an AI or LLM. label Aug 17, 2026
Comment thread Sources/Testing/Support/JSON.swift Outdated

@stmontgomery stmontgomery left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from @grynspan's remaining style comment, this looks good to me now, thank you!

@Kyle-Ye
Kyle-Ye force-pushed the bugfix/fix-exit-test-non-finite-floats branch from 9b7567b to 9b1b1d2 Compare August 18, 2026 14:52
@Kyle-Ye
Kyle-Ye requested a review from grynspan August 18, 2026 15:00
@Kyle-Ye
Kyle-Ye force-pushed the bugfix/fix-exit-test-non-finite-floats branch from 9b1b1d2 to 16037ea Compare August 18, 2026 15:01
@Kyle-Ye

Kyle-Ye commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

@grynspan The style issue is fixed. Any other suggestion?

@grynspan

Copy link
Copy Markdown
Contributor

Thanks!

@grynspan
grynspan merged commit 40b575e into swiftlang:main Aug 18, 2026
27 checks passed
@Kyle-Ye
Kyle-Ye deleted the bugfix/fix-exit-test-non-finite-floats branch August 18, 2026 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted 🤖 This issue or pull request was created (in whole or in part) by an AI or LLM. enhancement New feature or request exit-test-capture-lists 🥍 Work related to exit test capture lists exit-tests ☠️ Work related to exit tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exit test value capture fails for non-finite floating-point values

3 participants