diff options
author | Koichi ITO <[email protected]> | 2024-08-14 11:46:59 +0900 |
---|---|---|
committer | git <[email protected]> | 2024-08-14 16:28:43 +0000 |
commit | 88954a0e9a199156aadc472c4795133e5ac7651b () | |
tree | bdda97ffcaf793c6b87ca1ca3dfdf0695dfcfbf0 /lib/prism/parse_result.rb | |
parent | 264175dbb9e9f3c6721b1a4e28fd6cc379fda372 (diff) |
[ruby/prism] Tweak inspect representation of `Prism::Location`
This PR tweaks inspect representation of `Prism::Location`. ## Before During debugging, the meaning of `@location=https://.com/ruby/prism/commit/21474836481` was unclear: ```console $ ruby -Ilib -rprism -e 'p Prism.lex("puts :hi").value.map(&:first)[1]' #<Prism::Token:0x000000010cd74e40 @source=#<Prism::ASCIISource:0x000000010cb5f808 @source="puts :hi", @start_line=1, @offsets=[0]>, @type=:SYMBOL_BEGIN, @value=":", @location=https://.com/ruby/prism/commit/21474836481> ``` ## After This PR clarifies the contents of the location object, aligning with what I think user expects: ```console $ ruby -Ilib -rprism -e 'p Prism.lex("puts :hi").value.map(&:first)[1]' #<Prism::Token:0x000000010e174d50 @source=#<Prism::ASCIISource:0x000000010df5efe8 @source="puts :hi", @start_line=1, @offsets=[0]>, @type=:SYMBOL_BEGIN, @value=":", @location=#<Prism::Location @start_offset=5 @length=1 start_line=1>> ``` Although it is uncertain whether Prism will accept this change in the inspect representation, it is submitted here as a suggestion. https://.com/ruby/prism/commit/e7421ce1c5
-rw-r--r-- | lib/prism/parse_result.rb | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -711,5 +711,11 @@ module Prism other.type == type && other.value == value end end end |