Skip to content

fix(jq): print numbers and value errors like jq - #2595

Merged
chaliy merged 1 commit into
mainfrom
claude/project-thread-1mku65
Oct 7, 2026
Merged

chaliy merged 1 commit into
mainfrom
claude/project-thread-1mku65

Conversation

@chaliy

@chaliy chaliy commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Михайло · project thread

What changed

jq numbers and value errors now follow jq:

  • Number output. Computed floats print the way jq prints them: 1024, 1e+17, 1e-05, NaN as null, and infinities as the largest double. Number literals in the input keep their form until they are computed on, so 1.0 stays 1.0.
  • Arithmetic. Division by zero and % 0 are runtime errors. % truncates its operands.
  • Indexing. A fractional array index truncates. Indexing an object with a non-string is an error.
  • Math filters. gamma is log-gamma. nan, infinite and related filters no longer depend on dividing by zero.
  • Error text. Math and index errors use jq's wording, also inside try ... catch.

These are patched into the vendored jaq-json: jqmsg.rs, jq_format_f64 and defs.jq.

Why

This is the second jq batch from the pseudo-linus Debian oracle bench. Number formatting and error text were the next most common mismatches with real jq.

Before

Float results used jaq's formatting, dividing by zero produced infinity, and error text used jaq's wording. Oracle bench: jq 74.2%.

After

$ jq -nc '1024/1, (try (1/0) catch .), (try ("a"+1) catch .), 1.0'
1024
"number (1) and number (0) cannot be divided because the divisor is zero"
"string (\"a\") and number (1) cannot be added"
1.0

Oracle bench: jq 75.8%.

Risk

Low. The changes are confined to the jq value type, integer paths are unchanged, and the TM-DOS-110 meter patches are untouched. L-JQ-004 records the remaining literal-preservation gap.

Checklist

  • Unit tests (positive and negative); vendored math_rem test regenerated against jq 1.7
  • cargo clippy -D warnings, cargo fmt
  • Docs (jq.md Numbers), limitations, jaq-json-vendor knowledge and log updated

https://claude.ai/code/session_01VscpEzxtqpCKx5eRMpywNj

Computed floats use jq's formatting (1024, 1e+17, 1e-05, NaN as null),
input literals keep their token until computed, division and % by zero
are errors, % truncates operands, fractional array indexes truncate,
gamma is log-gamma, and math/index errors use jq's wording.

Claude-Session: https://claude.ai/code/session_01VscpEzxtqpCKx5eRMpywNj
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit f1b5909 Commit Preview URL

Branch Preview URL
Oct 07 2026, 08:28 PM

@chaliy
chaliy merged commit 7fa0108 into main Oct 7, 2026
47 checks passed
@chaliy
chaliy deleted the claude/project-thread-1mku65 branch October 7, 2026 21:02
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