Skip to content

Fix source mapping so backtraces report original file paths#11

Merged
JPDuchesne merged 1 commit intomasterfrom
jpd/source-mapping-fix
Feb 25, 2026
Merged

Fix source mapping so backtraces report original file paths#11
JPDuchesne merged 1 commit intomasterfrom
jpd/source-mapping-fix

Conversation

@JPDuchesne
Copy link
Contributor

Summary

  • Compile RubyVM::InstructionSequence with the original source_path instead of the tmp/ rewritten path, so caller and backtrace entries reference the real source file
  • Register source maps by both the transformed and original file paths, so downstream consumers (e.g. RSpock's BacktraceFilter) can look up mappings by either key
  • Replace File.read + regex with File.binread + String#include? for the transform! fast-path check — avoids encoding errors in locale-less environments (CI containers, sandboxes) where Encoding.default_external is US-ASCII; downstream (Prism, ISeq compiler) handle encoding natively via magic comments

Test plan

  • New test: source map is retrievable by source file path
  • New test: compiled iseq reports original source path
  • New tests: binread with include? handles non-ASCII content
  • Tests written first against unfixed code (confirmed failing), then verified passing after fix
  • Full suite: 43 tests, 0 failures

Made with Cursor

@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@JPDuchesne JPDuchesne force-pushed the jpd/source-mapping-fix branch from 22c13f4 to 394bc7c Compare February 25, 2026 17:16
- Compile ISeq with original source_path instead of tmp/ rewritten path
- Register source maps by both transformed and source file paths
- Use File.binread for transform! detection to avoid encoding issues
  in locale-less environments (CI, containers)

Co-authored-by: Cursor <cursoragent@cursor.com>
@JPDuchesne JPDuchesne force-pushed the jpd/source-mapping-fix branch from 394bc7c to e65a92c Compare February 25, 2026 17:24
@JPDuchesne JPDuchesne merged commit c444c54 into master Feb 25, 2026
4 checks passed
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