Skip to content

fix: report line-local columns for VM events#3623

Open
wuyua9 wants to merge 1 commit into
BoundaryML:canaryfrom
wuyua9:fix-send-event-source-column
Open

fix: report line-local columns for VM events#3623
wuyua9 wants to merge 1 commit into
BoundaryML:canaryfrom
wuyua9:fix-send-event-source-column

Conversation

@wuyua9

@wuyua9 wuyua9 commented May 31, 2026

Copy link
Copy Markdown

Summary

  • track the 0-indexed source column alongside each bytecode line-table entry
  • preserve that column when lowering bytecode to compact form
  • use the recorded line-local column for SendEvent source locations while keeping start/end offsets unchanged

Tests

  • rustfmt --edition 2024 baml_language/crates/baml_compiler2_emit/src/emit.rs baml_language/crates/bex_vm/src/vm.rs baml_language/crates/bex_vm_types/src/bytecode.rs
  • git diff --check
  • Not run: cargo test -p bex_vm_types line_table_translated --manifest-path baml_language/Cargo.toml cannot link in this local macOS environment because xcrun fails to load the installed CommandLineTools libxcrun.dylib as arm64/arm64e while compiling build scripts.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced source location tracking to include precise column offsets alongside line numbers in debug information, enabling more accurate error reporting and debugging capabilities.

@vercel

vercel Bot commented May 31, 2026

Copy link
Copy Markdown

@wuyua9 is attempting to deploy a commit to the Boundary Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 04539885-9dcb-4ed4-903a-bfcae2768031

📥 Commits

Reviewing files that changed from the base of the PR and between 066b6cb and 3596629.

📒 Files selected for processing (3)
  • baml_language/crates/baml_compiler2_emit/src/emit.rs
  • baml_language/crates/bex_vm/src/vm.rs
  • baml_language/crates/bex_vm_types/src/bytecode.rs

📝 Walkthrough

Walkthrough

This PR extends debug source mapping to track column offsets alongside line numbers. The compiler now computes 0-indexed columns during line-table generation, stores them in bytecode entries, propagates them through compact bytecode, and uses them in VM event emission.

Changes

Column Offsets in Source Location Tracking

Layer / File(s) Summary
LineTableEntry struct definition
baml_language/crates/bex_vm_types/src/bytecode.rs
New column: u32 field added to LineTableEntry for per-bytecode column metadata.
Line and column computation helpers
baml_language/crates/baml_compiler2_emit/src/emit.rs
offset_to_line_column and span_to_line_column replace line-only helpers, computing columns from source offsets while preserving prior normalization and fallback logic.
LineTableEntry emission with column
baml_language/crates/baml_compiler2_emit/src/emit.rs
Line-table emission updated to destructure (line, column) tuples and populate both fields in LineTableEntry structs.
Bytecode compact translation of column
baml_language/crates/bex_vm_types/src/bytecode.rs
Bytecode::lower_to_compact() now copies the new column field when translating line-table entries.
VM event emission with column
baml_language/crates/bex_vm/src/vm.rs
SendEvent opcode handling updated to use entry.column from bytecode instead of deriving it from span offset.
Line table translation test updates
baml_language/crates/bex_vm_types/src/bytecode.rs
Test constructs LineTableEntry with column values and asserts correct column propagation through compaction.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A column's found alongside each line,
From source offsets, the coords align,
Through bytecode flows, the metadata glides,
Till VM events show where error resides! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding column information to VM event source locations.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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