Age | Commit message (Collapse) | Author |
|
When parent scopes around an eval are forwarding parameters (like
*, **, &, 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
|
|
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
|
|
https://github.com/ruby/prism/commit/6b6aa05bfb
|
|
https://github.com/ruby/prism/commit/098f1c4607
|
|
https://github.com/ruby/prism/commit/a4fcd5339a
|
|
https://github.com/ruby/prism/commit/b28877fa4f
|
|
https://github.com/ruby/prism/commit/0b527ca93f
|
|
Fixes [Bug #20730]
Notes:
Merged: https://github.com/ruby/ruby/pull/11617
|
|
Add the ability to receive a callback when the parser encounters a
shebang that contains additional switches after the Ruby engine.
This is necessary because some command-line flags may be present
there that will alter the parse.
https://github.com/ruby/prism/commit/afc5000331
|
|
https://github.com/ruby/prism/commit/f7faedfb3f
|
|
https://github.com/ruby/prism/commit/445a0f0d22
|
|
https://github.com/ruby/prism/commit/f9a1abbc64
|
|
https://github.com/ruby/prism/commit/2068e3c30a
|
|
https://github.com/ruby/prism/commit/097fd2a54f
|
|
An explicit `false` is not equivalent to the comment being missing,
because the default can be switched with a runtime flag:
```bash
$ ruby --enable-frozen-string-literal -e 'p "foo".frozen?'
true
```
https://github.com/ruby/prism/commit/4660f58775
|
|
https://github.com/ruby/prism/commit/665f533373
|
|
- Add `x` prefix to malloc, calloc, realloc, and free
(eg: malloc -> xmalloc)
- By default, they are replaced with stdlib's functions at build
- You can use custom functions by defining `PRISM_CUSTOM_ALLOCATOR` macro
https://github.com/ruby/prism/commit/7a878af619
|
|
https://github.com/ruby/prism/commit/369ffbd57e
|
|
https://github.com/ruby/prism/commit/959eb506ca
|
|
https://github.com/ruby/prism/commit/2e8bc17528
|
|
This is effectively an alias for "latest" right now. In the future
it will change to be its own enum value.
https://github.com/ruby/prism/commit/2c86036022
|
|
This PR fixes following error when using `version: latest` argument.
```console
$ ruby -rprism -e "p Prism.parse('-> { it }', version: 'latest')"
-e:1:in `parse': invalid version: latest (ArgumentError)
p Prism.parse('-> { it }', version: 'latest')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
from -e:1:in `<main>'
```
The argument `version: latest` in the added test is commented as potentially being
better replaced with `version: 3.4.0` in the future.
https://github.com/ruby/prism/commit/27b5c933cb
|
|
|
|
Because this is a user-facing change, we also need to deal with the
fact that CRuby 3.3.0 was just released.
In order to support workflows that want to parse exactly as CRuby
parses in a specific version, this PR introduces a new option to
the options struct that is "version". This allows you to specify
that you want "3.3.0" parsing.
I'm not sure if this is the correct solution. Another solution is
to just fork and keep around the old branch for security patches.
Or we could keep around a copy of the source files within this
repository as another directory and only update when necessary.
There are a lot of potential solutions here.
Because this change is so small and the check for it is so minimal,
I've decided to go with this enum. If this ends up entirely
cluttering the codebase with version checks, we'll come up with
another solution. But for now this works, so we're going to go in
this direction for a bit until we determine it's no longer working.
https://github.com/ruby/prism/commit/d8c7e6bd10
|
|
Ruby allows for 0 or negative line start, this is often used
with `eval` calls to get a correct offset when prefixing a snippet.
e.g.
```ruby
caller = caller_locations(1, 1).first
class_eval <<~RUBY, caller.path, caller.line - 2
# frozen_string_literal: true
def some_method
#{caller_provided_code_snippet}
end
RUBY
```
https://github.com/ruby/prism/commit/0d14ed1452
|
|
https://github.com/ruby/prism/commit/f0aa8ad93b
|
|
https://github.com/ruby/prism/commit/99e81619de
|