Skip to content

fix: Also fix VLQ bug during encoding - #144

Merged
loewenheim merged 3 commits into
masterfrom
sebastian/vlq-write
Nov 26, 2026
Merged

loewenheim merged 3 commits into
masterfrom
sebastian/vlq-write

Conversation

@loewenheim

@loewenheim loewenheim commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Same bug as was fixed in #143, but in encoding instead of decoding.

@loewenheim
loewenheim requested a review from a team November 26, 2026 12:03
Comment thread src/vlq.rs Outdated
Comment on lines +362 to +363
let rv = generate_vlq_segment(&[u32::MIN as i64]).unwrap();
assert_eq!(rv.as_str(), "B");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Encode test uses u32::MIN instead of i32::MIN, so it fails

generate_vlq_segment(&[u32::MIN as i64]) encodes 0 as "A", but the assertion expects "B"; the input should be i32::MIN as i64 to match the new encode path and the decode test.

Evidence
  • Decode test asserts parse_vlq_segment("B") == [i32::MIN as i64] and encode_vlq special-cases only num == i32::MIN as i64 to emit digit 1 ("B").
  • Added encode test passes u32::MIN as i64, which is 0, not i32::MIN as i64 (-2147483648).
  • For 0, encode_vlq takes the num << 1 branch and emits "A", so assert_eq!(rv.as_str(), "B") fails deterministically.

Identified by Warden · code-review · CUZ-BYT

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a0758d2. Configure here.

Comment thread src/vlq.rs Resolved
@loewenheim
loewenheim merged commit 499ada5 into master Nov 26, 2026
15 checks passed
@loewenheim
loewenheim deleted the sebastian/vlq-write branch November 26, 2026 12:48
kdy1 added a commit to swc-project/swc-sourcemap that referenced this pull request Nov 27, 2026
## Summary

Merge upstream `getsentry/rust-sourcemap` `master` (head `499ada5`) into
the fork. The merge uses a merge commit.

Merged upstream commits:

- `f80828d` feat: Support for parsing scopes (getsentry#142)
- `499ada5` fix: Also fix VLQ bug during encoding (getsentry#144)

## Conflict resolution

- `src/types/mod.rs`: The fork's `Cow` and `BytesStr` changes stay. The
upstream `BTreeMap` import and `scopes` field are added. The upstream
removal of `#[allow(clippy::ptr_arg)]` on `create_ranges` is applied.
- `src/types/scope.rs`: `OriginalScope::get_name` and
`OriginalScope::get_kind` now return `Option<&BytesStr>`. This matches
the fork's `SourceMap::get_name` API.

## Validation

Local checks on the merge commit: `cargo build --all-targets` and `cargo
test --all-features` pass. `cargo fmt --check` passes after formatting.
`cargo clippy` is not installed for the local toolchain, so it did not
run. CI has not run yet.
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.

2 participants