Skip to content

fix: runtime error for json.parse invalid input (#295)#295

Merged
cs01 merged 1 commit intomainfrom
fallible-yyjson-bridge
Mar 12, 2026
Merged

fix: runtime error for json.parse invalid input (#295)#295
cs01 merged 1 commit intomainfrom
fallible-yyjson-bridge

Conversation

@cs01
Copy link
Copy Markdown
Owner

@cs01 cs01 commented Mar 12, 2026

Summary

  • JSON.parse<number[]> with invalid input now prints a clear error message and exits instead of returning a null pointer (which caused segfaults on subsequent array access)
  • JSON.parse (typed object parse) retains safe behavior: returns default-initialized struct on invalid JSON (empty strings, 0 for numbers)
  • Untyped JSON.parse already had error handling (no change)
  • Adds test fixture for invalid JSON input

Part of fallible C bridges work (#41 in future-work.md).

Test plan

  • npm run verify:quick passes
  • New test json-parse-invalid.ts exits with code 1 and error message
  • Existing json-safe-parse-test.ts still passes (typed parse returns defaults)

🤖 Generated with Claude Code

…turning null pointer

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cs01 cs01 merged commit 2720769 into main Mar 12, 2026
12 checks passed
@cs01 cs01 deleted the fallible-yyjson-bridge branch March 12, 2026 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant