summaryrefslogtreecommitdiff
path: root/test/ruby/test_transcode.rb
diff options
context:
space:
mode:
authorThomas Marshall <thomas@thomasmarshall.com>2025-12-29 12:55:18 +0000
committergit <svn-admin@ruby-lang.org>2025-12-29 14:12:20 +0000
commit14fbcf0e6ed37c4a0d15fd3f016778465f774f2c (patch)
tree89668533381771c98cc9722862864227d1571f04 /test/ruby/test_transcode.rb
parent8afd4fade69b3a53a5e309499595f7b192f87726 (diff)
[ruby/prism] Report missing end errors at opening token
This commit adds an `expect1_opening` function that expects a token and attaches the error to the opening token location rather than the current position. This is useful for errors about missing closing tokens, where we want to point to the line with the opening token rather than the end of the file. For example: ```ruby def foo def bar def baz ^ expected an `end` to close the `def` statement ^ expected an `end` to close the `def` statement ^ expected an `end` to close the `def` statement ``` This would previously produce three identical errors at the end of the file. After this commit, they would be reported at the opening token location: ```ruby def foo ^~~ expected an `end` to close the `def` statement def bar ^~~ expected an `end` to close the `def` statement def baz ^~~ expected an `end` to close the `def` statement ``` I considered using the end of the line where the opening token is located, but in some cases that would be less useful than the opening token location itself. For example: ```ruby def foo def bar def baz ``` Here the end of the line where the opening token is located would be the same for each of the unclosed `def` nodes. https://github.com/ruby/prism/commit/2d7829f060
Diffstat (limited to 'test/ruby/test_transcode.rb')
0 files changed, 0 insertions, 0 deletions