Skip to content

Conversation

@eregon
Copy link
Member

@eregon eregon commented Dec 16, 2025

Also:

  • [Bug #21783] Fix documentation of {Method,UnboundMethod,Proc}#source_location
  • [Bug #21784] Fix the Proc#source_location start_column for stabby lambdas

So this PR fixes all known issues about {Method,UnboundMethod,Proc}#source_location.

* This reverts commit 065c48c.
* This functionality is very valuable and has already taken 14 years
  to agree on the API.
* Let's just document it's byte columns (in the next commit).
* See https://bugs.ruby-lang.org/issues/21783#note-9
Copy link
Member

@nobu nobu left a comment

Choose a reason for hiding this comment

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

I think we should avoid the word “column” in the documents, because of the ambiguities.

@eregon
Copy link
Member Author

eregon commented Dec 16, 2025

Good point, especially since column might imply it starts at 1.
Do you have any suggestion?
The current text in 2d579f8 is:

(3) the column where the definition starts, in number of bytes from the start of the line

So maybe:

(3) the byte index where the definition starts, counted from the start of the line

(using matz's words from https://bugs.ruby-lang.org/issues/21783#note-8)
or

(3) the position where the definition starts, in number of bytes from the start of the line

?
Let me know what you think is better, happy to update.

…bdas

* Consistent with plain `blocks` and `for` blocks and methods
  where the source_location covers their entire definition.
* Matches the documentation which mentions
  "where the definition starts/ends".
* Partially reverts d357d50
  which was a workaround to be compatible with parse.y.
@eregon eregon force-pushed the source_location_byte_columns_for_4_0 branch from 7ac7008 to a1c18d0 Compare December 16, 2025 13:35
@eregon
Copy link
Member Author

eregon commented Dec 16, 2025

I have updated to this one for now:

(3) the position where the definition starts, in number of bytes from the start of the line

because "byte index" sounds to me rather confusing in this context.

@kddnewton
Copy link
Contributor

I'm fine with the code in here, pending approval from whomever makes the final decision.

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.

3 participants