Skip to content

Commit 08ffde5

Browse files
authored
Merge pull request #262 from stepchowfun/varint-serialization-bug
Fix a bug in the varint serialization logic
2 parents de9dc2a + 03ea87b commit 08ffde5

5 files changed

Lines changed: 18 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.0.7] - 2021-10-25
9+
10+
### Fixed
11+
- Fixed a bug in the variable-width integer serialization logic for Rust which affected numbers in the range [`567,382,630,219,904`, `72,624,976,668,147,840`).
12+
813
## [0.0.6] - 2021-10-24
914

1015
### Changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "typical"
3-
version = "0.0.6"
3+
version = "0.0.7"
44
authors = ["Stephan Boyer <stephan@stephanboyer.com>"]
55
edition = "2021"
66
description = "Algebraic data types for data interchange."

integration_tests/rust/src/comprehensive.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,15 @@ pub fn run() -> io::Result<()> {
176176
for i in i64::MIN..=i64::MIN + 1000 {
177177
check_match::<BarOut, BarIn>(BarOut::WRequired(i))?;
178178
}
179+
for i in (i64::MIN >> 32) - 1000..=(i64::MIN >> 32) + 1000 {
180+
check_match::<BarOut, BarIn>(BarOut::WRequired(i))?;
181+
}
179182
for i in -1000_i64..=1000_i64 {
180183
check_match::<BarOut, BarIn>(BarOut::WRequired(i))?;
181184
}
185+
for i in (i64::MAX >> 32) - 1000..=(i64::MAX >> 32) + 1000 {
186+
check_match::<BarOut, BarIn>(BarOut::WRequired(i))?;
187+
}
182188
for i in i64::MAX - 1000..=i64::MAX {
183189
check_match::<BarOut, BarIn>(BarOut::WRequired(i))?;
184190
}
@@ -190,6 +196,9 @@ pub fn run() -> io::Result<()> {
190196
for i in u64::MIN..=u64::MIN + 1000 {
191197
check_match::<BarOut, BarIn>(BarOut::YRequired(i))?;
192198
}
199+
for i in (u64::MAX >> 32) - 1000..=(u64::MAX >> 32) + 1000 {
200+
check_match::<BarOut, BarIn>(BarOut::YRequired(i))?;
201+
}
193202
for i in u64::MAX / 2 - 1000..=u64::MAX / 2 + 1000 {
194203
check_match::<BarOut, BarIn>(BarOut::YRequired(i))?;
195204
}

src/generate_rust.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ fn serialize_varint<T: Write>(mut value: u64, writer: &mut T) -> io::Result<()>
177177
])
178178
}}
179179
567_382_630_219_904_u64..=72_624_976_668_147_839_u64 => {{
180-
value -= 72_624_976_668_147_839_u64;
180+
value -= 567_382_630_219_904_u64;
181181
writer.write_all(&[
182182
0b1000_0000,
183183
value as u8,
@@ -2011,7 +2011,7 @@ fn serialize_varint<T: Write>(mut value: u64, writer: &mut T) -> io::Result<()>
20112011
])
20122012
}
20132013
567_382_630_219_904_u64..=72_624_976_668_147_839_u64 => {
2014-
value -= 72_624_976_668_147_839_u64;
2014+
value -= 567_382_630_219_904_u64;
20152015
writer.write_all(&[
20162016
0b1000_0000,
20172017
value as u8,

0 commit comments

Comments
 (0)