Skip to content

Release 0.2.0: fallible numeric conversions and chained-expression fixes - #29

Merged
davassi merged 1 commit into
masterfrom
release-0.2.0
Aug 3, 2026
Merged

Release 0.2.0: fallible numeric conversions and chained-expression fixes#29
davassi merged 1 commit into
masterfrom
release-0.2.0

Conversation

@davassi

@davassi davassi commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Summary

Release 0.2.0. Makes numeric conversions fallible instead of panicking, fixes chained-expression handling, and grows the test suite from 36 to 64 tests.

Breaking change

From<Number> for i32/i64/i128/f64 panicked on out-of-range or non-finite values. It is replaced by TryFrom<Number>, which returns a ConversionError. Callers doing i64::from(n) must move to i64::try_from(n)?.

From<Number> for BigInt is kept but is now exact: it truncates the rational toward zero instead of round-tripping through f64, so large values no longer lose precision.

Fixes

  • A trailing ; reported a spurious malformed-expression error after the assignment side-effect had already been applied. Chained expressions now return the last segment's value, and genuinely malformed segments are rejected.
  • Removed the unused BitXor implementation for Number, which panicked internally.

Tests

36 → 64 tests, covering fallible/exact conversions, rounding on negatives, power edge cases, domain errors, variable case-insensitivity, chained assignment, square/mixed brackets, whitespace handling, decimal-literal parsing, and the Number Display / ConversionError messages.

Verification

cargo test passes locally: 28 integration tests, 31 unit tests, 5 doc-tests, 0 failures.


Summary by cubic

Release 0.2.0 makes numeric conversions from Number fallible and fixes ;-chained expressions to return the last segment’s value. It also removes a panicking BitXor and expands test coverage.

  • Migration

    • Replace into() calls with try_into()/TryFrom and handle ConversionError (e.g. let x: i64 = n.try_into()?;) for i32, i64, i128, and f64.
    • From<Number> for BigInt stays, and is now exact: it truncates toward zero without an f64 round-trip.
  • Bug Fixes

    • Chained expressions: trailing ; returns the last segment’s value; malformed segments now error; assignment side-effects and reported values are consistent.
    • Removed an unused BitXor on Number that could panic.

Written for commit d4e035d. Summary will update on new commits.

Review in cubic

- Replace the panicking From<Number> for i32/i64/i128/f64 with fallible TryFrom
  returning a ConversionError; keep From<Number> for BigInt but make it exact
  (truncate the rational toward zero instead of round-tripping through f64).
- Fix a trailing ';' reporting a spurious malformed-expression error after the
  assignment side-effect had already taken place; return the last segment's
  value and reject malformed chained segments.
- Remove the unused, internally-panicking BitXor implementation for Number.
- Grow the test suite from 36 to 64 tests: fallible/exact conversions, rounding
  on negatives, power edge cases, domain errors, variable case-insensitivity,
  chained assignment, square/mixed brackets, whitespace, decimal-literal parsing,
  Number Display and ConversionError messages.
- Bump version to 0.2.0 and document the breaking change in the README.
@davassi
davassi merged commit 001616a into master Aug 3, 2026
2 checks passed
@davassi
davassi deleted the release-0.2.0 branch August 3, 2026 16:57
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