<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/prism/extension.c, branch v4.0.4</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] Create a new string for the current version error</title>
<updated>2025-10-16T14:00:28+00:00</updated>
<author>
<name>Kevin Newton</name>
<email>kddnewton@gmail.com</email>
</author>
<published>2025-10-16T13:59:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=6652d5072fa4888443d43db0a4026524b56925bf'/>
<id>6652d5072fa4888443d43db0a4026524b56925bf</id>
<content type='text'>
https://github.com/ruby/prism/commit/ebf4425d49
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/prism/commit/ebf4425d49
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/prism] Add support for `Prism.parse(foo, version: "current")`</title>
<updated>2025-10-16T12:34:14+00:00</updated>
<author>
<name>Earlopain</name>
<email>14981592+Earlopain@users.noreply.github.com</email>
</author>
<published>2025-10-15T06:46:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=f5d3b6e6261569a7205b637052d1fec45ae4620b'/>
<id>f5d3b6e6261569a7205b637052d1fec45ae4620b</id>
<content type='text'>
The docs currently say to use `Prism.parse(foo, version: RUBY_VERSION)` for this.
By specifying "current" instead, we can have prism raise a more specifc error.

Note: Does not use `ruby_version` from `ruby/version.h` because writing a test for that is not really possible.
`RUBY_VERSION` is nicely stubbable for both the c-ext and FFI backend.

https://github.com/ruby/prism/commit/9c5cd205cf
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The docs currently say to use `Prism.parse(foo, version: RUBY_VERSION)` for this.
By specifying "current" instead, we can have prism raise a more specifc error.

Note: Does not use `ruby_version` from `ruby/version.h` because writing a test for that is not really possible.
`RUBY_VERSION` is nicely stubbable for both the c-ext and FFI backend.

https://github.com/ruby/prism/commit/9c5cd205cf
</pre>
</div>
</content>
</entry>
<entry>
<title>When reading from stdin, put a wrapper around the IO object</title>
<updated>2025-08-04T19:34:33+00:00</updated>
<author>
<name>Aaron Patterson</name>
<email>tenderlove@ruby-lang.org</email>
</author>
<published>2025-07-17T22:20:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=89d89fa49d387a09e0d3ea7092a598b88d6d86eb'/>
<id>89d89fa49d387a09e0d3ea7092a598b88d6d86eb</id>
<content type='text'>
The purpose of this commit is to fix Bug #21188.  We need to detect when
stdin has run in to an EOF case.  Unfortunately we can't _call_ the eof
function on IO because it will block.

Here is a short script to demonstrate the issue:

```ruby
x = STDIN.gets
puts x
puts x.eof?
```

If you run the script, then type some characters (but _NOT_ a newline),
then hit Ctrl-D twice, it will print the input string.  Unfortunately,
calling `eof?` will try to read from STDIN again causing us to need a
3rd Ctrl-D to exit the program.

Before introducing the EOF callback to Prism, the input loop looked
kind of like this:

```ruby
loop do
  str = STDIN.gets
  process(str)

  if str.nil?
    p :DONE
  end
end
```

Which required 3 Ctrl-D to exit.  If we naively changed it to something
like this:

```ruby
loop do
  str = STDIN.gets
  process(str)

  if STDIN.eof?
    p :DONE
  end
end
```

It would still require 3 Ctrl-D because `eof?` would block.  In this
patch, we're wrapping the IO object, checking the buffer for a newline
and length, and then using that to simulate a non-blocking eof? method.

This commit wraps STDIN and emulates a non-blocking `eof` function.

[Bug #21188]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The purpose of this commit is to fix Bug #21188.  We need to detect when
stdin has run in to an EOF case.  Unfortunately we can't _call_ the eof
function on IO because it will block.

Here is a short script to demonstrate the issue:

```ruby
x = STDIN.gets
puts x
puts x.eof?
```

If you run the script, then type some characters (but _NOT_ a newline),
then hit Ctrl-D twice, it will print the input string.  Unfortunately,
calling `eof?` will try to read from STDIN again causing us to need a
3rd Ctrl-D to exit the program.

Before introducing the EOF callback to Prism, the input loop looked
kind of like this:

```ruby
loop do
  str = STDIN.gets
  process(str)

  if str.nil?
    p :DONE
  end
end
```

Which required 3 Ctrl-D to exit.  If we naively changed it to something
like this:

```ruby
loop do
  str = STDIN.gets
  process(str)

  if STDIN.eof?
    p :DONE
  end
end
```

It would still require 3 Ctrl-D because `eof?` would block.  In this
patch, we're wrapping the IO object, checking the buffer for a newline
and length, and then using that to simulate a non-blocking eof? method.

This commit wraps STDIN and emulates a non-blocking `eof` function.

[Bug #21188]
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/prism] Mark Prism as ractor-safe</title>
<updated>2025-03-19T21:11:57+00:00</updated>
<author>
<name>Kevin Newton</name>
<email>kddnewton@gmail.com</email>
</author>
<published>2025-03-19T20:50:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=641f15b1c6bd8921407a1f045573d3b0605f00d3'/>
<id>641f15b1c6bd8921407a1f045573d3b0605f00d3</id>
<content type='text'>
https://github.com/ruby/prism/commit/c02429765b
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/prism/commit/c02429765b
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/prism] Revert "Mark extension as Ractor-safe"</title>
<updated>2025-03-12T19:56:22+00:00</updated>
<author>
<name>Kevin Newton</name>
<email>kddnewton@gmail.com</email>
</author>
<published>2025-03-12T19:56:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=af76b7f4d9f791b8d20f567e0fa8a45488fa00b8'/>
<id>af76b7f4d9f791b8d20f567e0fa8a45488fa00b8</id>
<content type='text'>
https://github.com/ruby/prism/commit/56eaf53732
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/prism/commit/56eaf53732
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/prism] Mark extension as Ractor-safe</title>
<updated>2025-03-12T19:15:03+00:00</updated>
<author>
<name>Kevin Newton</name>
<email>kddnewton@gmail.com</email>
</author>
<published>2025-03-12T17:16:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=242e99eb0f32e1705413d084126be4ae6525a804'/>
<id>242e99eb0f32e1705413d084126be4ae6525a804</id>
<content type='text'>
https://github.com/ruby/prism/commit/10e5431b38
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/prism/commit/10e5431b38
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/prism] Freeze `Prism::VERSION`</title>
<updated>2025-01-19T12:44:20+00:00</updated>
<author>
<name>Earlopain</name>
<email>14981592+Earlopain@users.noreply.github.com</email>
</author>
<published>2025-01-19T11:22:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=f27ed98effff9891d28edc7119d45811bcedd510'/>
<id>f27ed98effff9891d28edc7119d45811bcedd510</id>
<content type='text'>
Closes https://github.com/ruby/prism/pull/3422

https://github.com/ruby/prism/commit/b488a84253
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Closes https://github.com/ruby/prism/pull/3422

https://github.com/ruby/prism/commit/b488a84253
</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] Freeze AST option</title>
<updated>2025-01-14T15:32:39+00:00</updated>
<author>
<name>Kevin Newton</name>
<email>kddnewton@gmail.com</email>
</author>
<published>2025-01-12T02:10:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=713f31872a42b75924d346ce5df3e567db074cc5'/>
<id>713f31872a42b75924d346ce5df3e567db074cc5</id>
<content type='text'>
To make it so that you can pass `freeze: true` to Prism parse
methods and get back a deeply-frozen AST that is Ractor-
shareable.

https://github.com/ruby/prism/commit/8e6a93b2d2
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
To make it so that you can pass `freeze: true` to Prism parse
methods and get back a deeply-frozen AST that is Ractor-
shareable.

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