Fix Ruby indexer keyword parameter offset to exclude trailing colon#706
Merged
Fix Ruby indexer keyword parameter offset to exclude trailing colon#706
Conversation
vinistock
approved these changes
Mar 27, 2026
rust/rubydex/src/offset.rs
Outdated
| /// # Panics | ||
| /// | ||
| /// Panics if shrinking would make `end` less than `start`. | ||
| pub fn shrink_end(&mut self, bytes: u32) { |
Member
There was a problem hiding this comment.
I vote for not allowing the offsets to be mutated and instead doing this inline:
let loc = required.name_loc();
let offset = Offset::new(loc.start_offset(), loc.end_offset() - 1);Prism's name_loc for keyword parameters includes the trailing colon (e.g. "name:"), but the offset should only cover the identifier. This aligns Ruby indexer behavior with the RBS indexer, which already excludes the colon. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
6359bdd to
ede6d74
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
nameinstead ofname:)Offset::shrink_endhelper with invariant checkingRubyIndexer::offset_to_stringto derive parameter name from the adjusted offsetAddresses feedback from #694 — Vini pointed out the Ruby indexer was incorrectly including the colon, and the RBS indexer had it right.
Test plan
index_def_node_with_parameterstest to assert keyword parameter offsets point to the identifier without the colon🤖 Generated with Claude Code