Skip to content

fix: require sonic-number >= 0.1.3 - #261

Draft
liuq19 wants to merge 1 commit into
cloudwego:mainfrom
liuq19:fix/sonic-number-min-version
Draft

liuq19 wants to merge 1 commit into
cloudwego:mainfrom
liuq19:fix/sonic-number-min-version

Conversation

@liuq19

@liuq19 liuq19 commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

src/parser.rs imports and calls APIs that exist only since sonic-number 0.1.3:

use sonic_number::{parse_float32, parse_number, ParserNumber};
// ...
let ret = unsafe { sonic_number::parse_number_unchecked(data, &mut now, neg) };

The root Cargo.toml however declares the dependency with a loose requirement:

sonic-number = { path = "./sonic-number", version = "0.1" }

When the crate is published, the path = "./sonic-number" is stripped and only the
version requirement remains. Because "0.1" (^0.1.0) admits 0.1.2, Cargo can keep
an older locked sonic-number 0.1.2 (e.g. from a downstream Cargo.lock), which does
not provide parse_float32 / parse_number_unchecked. This makes the published
sonic-rs 0.5.10 fail to build:

error[E0432]: unresolved import `sonic_number::parse_float32`
error[E0425]: cannot find function `parse_number_unchecked` in crate `sonic_number`

This is exactly the report in #246.

Change

Tighten the requirement so Cargo resolves to at least sonic-number 0.1.3:

-sonic-number = { path = "./sonic-number", version = "0.1" }
+sonic-number = { path = "./sonic-number", version = "0.1.3" }

sonic-number 0.1.3 is already the current sub-crate version in this repo and is
published on crates.io (max_version = 0.1.3), so the path/local build is unaffected.

Risk

Low and localized: a single manifest version-bump. No source changes.

Testing

  • cargo check --lib (default features) — passes
  • cargo test --lib (default features) — 114 passed, 0 failed
  • cargo check --lib --features utf8_lossy — passes

Refs #246

The root parser (src/parser.rs) uses sonic_number::parse_float32 and
sonic_number::parse_number_unchecked, both introduced in sonic-number 0.1.3.
The loose version = "0.1" requirement allows Cargo to resolve to
sonic-number 0.1.2 (e.g. when kept by an existing Cargo.lock), which makes
the published sonic-rs 0.5.10 fail to build with E0432/E0425.

Pin the requirement to "0.1.3" so Cargo selects at least sonic-number 0.1.3.

Fixes cloudwego#246
@codecov

codecov Bot commented Oct 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.36%. Comparing base (f63d185) to head (213e22a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #261   +/-   ##
=======================================
  Coverage   73.36%   73.36%           
=======================================
  Files          42       42           
  Lines       10030    10030           
=======================================
  Hits         7359     7359           
  Misses       2671     2671           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant