<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/lib/prism/parse_result.rb, branch v4.0.2</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>[ruby/prism] Optimize `Prism::Source#find_line`</title>
<updated>2025-11-29T19:01:11+00:00</updated>
<author>
<name>Earlopain</name>
<email>14981592+Earlopain@users.noreply.github.com</email>
</author>
<published>2025-11-26T15:13:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=48a73303e45b1dbaa3422e14e35c7834db98be4d'/>
<id>48a73303e45b1dbaa3422e14e35c7834db98be4d</id>
<content type='text'>
This is more concise and ruby does a better job performance-wise.

This used to be `bsearch_index` already but https://github.com/ruby/prism/commit/6d8358c08395438d5924777c1fc3001a5ebf0aa3 changed it.
https://github.com/ruby/prism/pull/1733#discussion_r1373702087 said:
&gt; Yeah the edge case was that the value matched an element exactly

But surely there would be a test to show this behaviour?

Gets called as part of pretty-printing nodes.
Further reduces the time for `SnapshotsTest` by ~16% for me.

https://github.com/ruby/prism/commit/f448e2b995
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is more concise and ruby does a better job performance-wise.

This used to be `bsearch_index` already but https://github.com/ruby/prism/commit/6d8358c08395438d5924777c1fc3001a5ebf0aa3 changed it.
https://github.com/ruby/prism/pull/1733#discussion_r1373702087 said:
&gt; Yeah the edge case was that the value matched an element exactly

But surely there would be a test to show this behaviour?

Gets called as part of pretty-printing nodes.
Further reduces the time for `SnapshotsTest` by ~16% for me.

https://github.com/ruby/prism/commit/f448e2b995
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/prism] [DOC] Specify markdown mode to RDoc</title>
<updated>2025-05-29T04:45:58+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2025-05-28T10:25:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=991cf2dd4d611d5a8b275dfb3ec83c4d25799629'/>
<id>991cf2dd4d611d5a8b275dfb3ec83c4d25799629</id>
<content type='text'>
https://github.com/ruby/prism/commit/12af4e144e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/prism/commit/12af4e144e
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/prism] Support forwarding flags on scopes</title>
<updated>2025-01-14T20:31:38+00:00</updated>
<author>
<name>Kevin Newton</name>
<email>kddnewton@gmail.com</email>
</author>
<published>2025-01-14T18:10:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=51d3d6ac8c2e3b6b6dacd80a9ddf11adc46fde08'/>
<id>51d3d6ac8c2e3b6b6dacd80a9ddf11adc46fde08</id>
<content type='text'>
When parent scopes around an eval are forwarding parameters (like
*, **, &amp;, or ...) we need to know that information when we are in
the parser. As such, we need to support passing that information
into the scopes option. In order to do this, unfortunately we need
a bunch of changes.

The scopes option was previously an array of array of strings.
These corresponded to the names of the locals in the parent scopes.
We still support this, but now additionally support passing in a
Prism::Scope instance at each index in the array. This Prism::Scope
class holds both the names of the locals as well as an array of
forwarding parameter names (symbols corresponding to the forwarding
parameters). There is convenience function on the Prism module that
creates a Prism::Scope object using Prism.scope.

In JavaScript, we now additionally support an object much the same
as the Ruby side. In Java, we now have a ParsingOptions.Scope class
that holds that information. In the dump APIs, these objects in all
3 languages will add an additional byte for the forwarding flags in
the middle of the scopes serialization.

All of this is in service of properly parsing the following code:

```ruby
def foo(*) = eval("bar(*)")
```

https://github.com/ruby/prism/commit/21abb6b7c4
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When parent scopes around an eval are forwarding parameters (like
*, **, &amp;, or ...) we need to know that information when we are in
the parser. As such, we need to support passing that information
into the scopes option. In order to do this, unfortunately we need
a bunch of changes.

The scopes option was previously an array of array of strings.
These corresponded to the names of the locals in the parent scopes.
We still support this, but now additionally support passing in a
Prism::Scope instance at each index in the array. This Prism::Scope
class holds both the names of the locals as well as an array of
forwarding parameter names (symbols corresponding to the forwarding
parameters). There is convenience function on the Prism module that
creates a Prism::Scope object using Prism.scope.

In JavaScript, we now additionally support an object much the same
as the Ruby side. In Java, we now have a ParsingOptions.Scope class
that holds that information. In the dump APIs, these objects in all
3 languages will add an additional byte for the forwarding flags in
the middle of the scopes serialization.

All of this is in service of properly parsing the following code:

```ruby
def foo(*) = eval("bar(*)")
```

https://github.com/ruby/prism/commit/21abb6b7c4
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/prism] Refactor serializer</title>
<updated>2025-01-14T15:32:41+00:00</updated>
<author>
<name>Kevin Newton</name>
<email>kddnewton@gmail.com</email>
</author>
<published>2025-01-13T01:06:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=da93c9ae29d2575aa2eb3a3a0868b3ca7e489576'/>
<id>da93c9ae29d2575aa2eb3a3a0868b3ca7e489576</id>
<content type='text'>
https://github.com/ruby/prism/commit/8ab2532f09
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/prism/commit/8ab2532f09
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/prism] Bump typechecking deps</title>
<updated>2024-12-11T19:50:20+00:00</updated>
<author>
<name>Kevin Newton</name>
<email>kddnewton@gmail.com</email>
</author>
<published>2024-12-11T19:09:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=34e68548d43175c5d496b533dec280e935a8d2d5'/>
<id>34e68548d43175c5d496b533dec280e935a8d2d5</id>
<content type='text'>
https://github.com/ruby/prism/commit/230c8b8a48
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/prism/commit/230c8b8a48
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/prism] Prism::CodeUnitsCache</title>
<updated>2024-10-10T18:02:27+00:00</updated>
<author>
<name>Kevin Newton</name>
<email>kddnewton@gmail.com</email>
</author>
<published>2024-10-09T18:40:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=7a198af7cdb437c5245ac3ab70cb66cef2002d06'/>
<id>7a198af7cdb437c5245ac3ab70cb66cef2002d06</id>
<content type='text'>
Calculating code unit offsets for a source can be very expensive,
especially when the source is large. This commit introduces a new
class that wraps the source and desired encoding into a cache that
reuses pre-computed offsets. It performs quite a bit better.

There are still some problems with this approach, namely character
boundaries and the fact that the cache is unbounded, but both of
these may be addressed in subsequent commits.

https://github.com/ruby/prism/commit/2e3e1a4d4d
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Calculating code unit offsets for a source can be very expensive,
especially when the source is large. This commit introduces a new
class that wraps the source and desired encoding into a cache that
reuses pre-computed offsets. It performs quite a bit better.

There are still some problems with this approach, namely character
boundaries and the fact that the cache is unbounded, but both of
these may be addressed in subsequent commits.

https://github.com/ruby/prism/commit/2e3e1a4d4d
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/prism] Attempt to assume binary is UTF-8</title>
<updated>2024-10-09T15:42:23+00:00</updated>
<author>
<name>Kevin Newton</name>
<email>kddnewton@gmail.com</email>
</author>
<published>2024-10-09T14:34:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=e39e582594feaeb40722b2921e8feb562d94269b'/>
<id>e39e582594feaeb40722b2921e8feb562d94269b</id>
<content type='text'>
https://github.com/ruby/prism/commit/343197e4ff
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/prism/commit/343197e4ff
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/prism] Avoid breaking code units offset on binary encoding</title>
<updated>2024-10-09T14:07:10+00:00</updated>
<author>
<name>Vinicius Stock</name>
<email>vinicius.stock@shopify.com</email>
</author>
<published>2024-10-08T14:47:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=e50754fcfaeb80bef93f043c13895ce386ddb18c'/>
<id>e50754fcfaeb80bef93f043c13895ce386ddb18c</id>
<content type='text'>
https://github.com/ruby/prism/commit/25a4cf6794

Co-authored-by: Kevin Newton &lt;kddnewton@users.noreply.github.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/prism/commit/25a4cf6794

Co-authored-by: Kevin Newton &lt;kddnewton@users.noreply.github.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/prism] essentialy ==&gt; essentially</title>
<updated>2024-09-04T13:13:37+00:00</updated>
<author>
<name>ydah</name>
<email>t.yudai92@gmail.com</email>
</author>
<published>2024-09-04T12:55:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=dbb8f97eaa4c6c7e36c797c7b1d9a803db2623ea'/>
<id>dbb8f97eaa4c6c7e36c797c7b1d9a803db2623ea</id>
<content type='text'>
https://github.com/ruby/prism/commit/9c68c01bcd
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/prism/commit/9c68c01bcd
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/prism] Tweak inspect representation of `Prism::Location`</title>
<updated>2024-08-14T16:28:43+00:00</updated>
<author>
<name>Koichi ITO</name>
<email>koic.ito@gmail.com</email>
</author>
<published>2024-08-14T02:46:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=88954a0e9a199156aadc472c4795133e5ac7651b'/>
<id>88954a0e9a199156aadc472c4795133e5ac7651b</id>
<content type='text'>
This PR tweaks inspect representation of `Prism::Location`.

## Before

During debugging, the meaning of `@location=https://github.com/ruby/prism/commit/21474836481` was unclear:

```console
$ ruby -Ilib -rprism -e 'p Prism.lex("puts :hi").value.map(&amp;:first)[1]'
#&lt;Prism::Token:0x000000010cd74e40 @source=#&lt;Prism::ASCIISource:0x000000010cb5f808 @source="puts :hi", @start_line=1, @offsets=[0]&gt;,
@type=:SYMBOL_BEGIN, @value=":", @location=https://github.com/ruby/prism/commit/21474836481&gt;
```

## 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(&amp;:first)[1]'
#&lt;Prism::Token:0x000000010e174d50 @source=#&lt;Prism::ASCIISource:0x000000010df5efe8 @source="puts :hi", @start_line=1, @offsets=[0]&gt;,
@type=:SYMBOL_BEGIN, @value=":", @location=#&lt;Prism::Location @start_offset=5 @length=1 start_line=1&gt;&gt;
```

Although it is uncertain whether Prism will accept this change in the inspect representation, it is submitted here as a suggestion.

https://github.com/ruby/prism/commit/e7421ce1c5
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This PR tweaks inspect representation of `Prism::Location`.

## Before

During debugging, the meaning of `@location=https://github.com/ruby/prism/commit/21474836481` was unclear:

```console
$ ruby -Ilib -rprism -e 'p Prism.lex("puts :hi").value.map(&amp;:first)[1]'
#&lt;Prism::Token:0x000000010cd74e40 @source=#&lt;Prism::ASCIISource:0x000000010cb5f808 @source="puts :hi", @start_line=1, @offsets=[0]&gt;,
@type=:SYMBOL_BEGIN, @value=":", @location=https://github.com/ruby/prism/commit/21474836481&gt;
```

## 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(&amp;:first)[1]'
#&lt;Prism::Token:0x000000010e174d50 @source=#&lt;Prism::ASCIISource:0x000000010df5efe8 @source="puts :hi", @start_line=1, @offsets=[0]&gt;,
@type=:SYMBOL_BEGIN, @value=":", @location=#&lt;Prism::Location @start_offset=5 @length=1 start_line=1&gt;&gt;
```

Although it is uncertain whether Prism will accept this change in the inspect representation, it is submitted here as a suggestion.

https://github.com/ruby/prism/commit/e7421ce1c5
</pre>
</div>
</content>
</entry>
</feed>
