Граф коммитов

50 Коммитов

Автор SHA1 Сообщение Дата
Kevin Newton 0b5be2f9e9 Sync to latest prism 2024-02-05 11:07:07 -05:00
Kevin Newton d39d9e066f [ruby/prism] Fix binding power for modifier rescue
https://github.com/ruby/prism/commit/f614863d79
2024-01-29 18:42:47 +00:00
Haldun Bayhantopcu 7d356b8f0e [ruby/prism] Fix multiple assigns with newlines
https://github.com/ruby/prism/commit/b4ba41bdcd
2024-01-26 18:35:54 +00:00
Haldun Bayhantopcu 9a7637da2d [ruby/prism] Add tests
https://github.com/ruby/prism/commit/b9ebf987bd
2024-01-26 18:32:31 +00:00
Max Prokopiev 8e5bc8f7c2 [ruby/prism] Change binding power for modifiers in case-in nodes
https://github.com/ruby/prism/commit/c31eeba54c
2024-01-26 18:32:02 +00:00
Max Prokopiev e9f936df71 [ruby/prism] Extract snippet into its own file and skip in TruffleRuby
https://github.com/ruby/prism/commit/12649ee74c
2024-01-24 20:32:02 +00:00
Max Prokopiev 91a5093c15 [ruby/prism] Force encoding during deserialization of constants
otherwise we get failing tests if we have non-ascii
characters in fixtures/**/*.txt

https://github.com/ruby/prism/commit/9323243569
2024-01-24 20:32:01 +00:00
Adam Hess 13879fea69 [ruby/prism] Fix prism brace association for constant-like method/local calls
https://github.com/ruby/prism/commit/8ca24f263e
2024-01-17 13:26:05 +00:00
TSUYUSATO Kitsune c5e43da426 [ruby/prism] Correct the "ambiguous first argument" condition
Fix https://github.com/ruby/prism/pull/2182

This change reflects this line:
6283ae8d36/parse.y (L11124).

https://github.com/ruby/prism/commit/a52588ff37
2024-01-16 15:51:09 +00:00
Aaron Patterson 881c5a1846 [ruby/prism] Add a "repeated flag" to parameter nodes
It's possible to repeat parameters in method definitions like so:

```ruby
def foo(_a, _a)
end
```

The compiler needs to know to adjust the local table size to account for
these duplicate names.  We'll use the repeated parameter flag to account
for the extra stack space required

https://github.com/ruby/prism/commit/b443cb1f60

Co-Authored-By: Kevin Newton <kddnewton@gmail.com>
Co-Authored-By: Jemma Issroff <jemmaissroff@gmail.com>
2024-01-10 15:24:26 +00:00
Kevin Newton 88d7838445 [ruby/prism] Fix assertion on spanning heredocs
https://github.com/ruby/prism/commit/e190308845
2024-01-09 15:15:52 +00:00
TSUYUSATO Kitsune a25329e0da [ruby/prism] Fix parsing pinned local variable pattern for numbered parameter
Fix https://github.com/ruby/prism/pull/2094

The part of `parse_variable_call` for variables was split into a new
function `parse_variable` and used it.

https://github.com/ruby/prism/commit/4c5fd1a746
2024-01-03 17:20:33 +00:00
Hiroshi SHIBATA fa251d60aa Revert "Revert all of commits after Prism 0.19.0 release"
This reverts commit d242e8416e.
2023-12-25 21:12:49 +09:00
Hiroshi SHIBATA d242e8416e
Revert all of commits after Prism 0.19.0 release
We should bundle released version of Prism for Ruby 3.3.0
2023-12-16 11:08:51 +08:00
Kevin Newton fe9b42f024 [ruby/prism] Invalid pinned locals in pattern matching
https://github.com/ruby/prism/commit/3a67b37a56
2023-12-15 15:03:49 +00:00
Kevin Newton 019fff3a86 [ruby/prism] Fix parse result for nesting pattern matching
https://github.com/ruby/prism/commit/ee6fc9ee87
2023-12-14 18:54:46 +00:00
Kevin Newton c65de63913 [ruby/prism] Handle a non-interpolated dsym spanning a heredoc
https://github.com/ruby/prism/commit/b23136ebfd
2023-12-11 16:34:41 +00:00
TSUYUSATO Kitsune a860e3605c [ruby/prism] Fix to parse a (endless-)range with binary operators
Fix https://github.com/ruby/prism/pull/2022
Fix https://github.com/ruby/prism/pull/2030

https://github.com/ruby/prism/commit/b78d8b6525
2023-12-11 13:34:48 +00:00
eileencodes a33632e1ca [ruby/prism] Fix defined with new line
It's possible to write the following and have it be valid Ruby:

```
defined?("foo"
)
```

But Prism wasn't taking the new line into account. This adds an
`accept1` for a `PM_TOKEN_NEWLINE` to account for this. I've also
updated the fixtures and snapshots to test this.

https://github.com/ruby/prism/commit/b87f8eedc6
2023-12-05 20:47:22 +00:00
TSUYUSATO Kitsune 3260ed7e5e [ruby/prism] Add test cases
https://github.com/ruby/prism/commit/e91f8dbb99
2023-12-05 15:16:42 +00:00
TSUYUSATO Kitsune 3d4a4b2529 [ruby/prism] Fix some corner cases
https://github.com/ruby/prism/commit/d5453f168e
2023-12-05 15:16:41 +00:00
TSUYUSATO Kitsune dcd75fd49d [ruby/prism] Fix to parse command-style method calls more correctly
Fix https://github.com/ruby/prism/pull/1468
Fix https://github.com/ruby/prism/pull/1575

To decide command-style method calls are allowed, this introduce a new
parameter `accepts_command_call` to `parse_expression` and some
functions.

Although one think this can be solved by operator precedence, it is
hard or impossible, because the precedence of command-style calls is skewed
(e.g. `! bar 1 ` is accepted, but `foo = ! bar 1` is rejected.)

One of the most complex examples is that:
(1) even though `foo = bar = baz 1` and `foo, bar = baz 1` is accepted,
(2) `foo, bar = baz = fuzz 1` is rejected.
To implement this behavior, this introduces a new binding power
`PM_BINDING_POWER_MULTI_ASSIGNMENT` and uses it for distinguish which single
assignments or multi assignments at their RHS.

https://github.com/ruby/prism/commit/d4dd49ca81
2023-12-05 15:16:40 +00:00
Haldun Bayhantopcu 562d949e02 [ruby/prism] Fix parsing heredoc ends
https://github.com/ruby/prism/commit/aa8c702271
2023-12-01 20:10:58 +00:00
Martin Emde cbe57caa24 [ruby/prism] Fix comments after HEREDOCs again.
The problem was deeper than just looking back a single token.
You can push the heredoc_end token way back into the list.
We need to save the last location of a heredoc end to see if
it's the last token in the file.

Fixes https://github.com/ruby/prism/pull/1954

https://github.com/ruby/prism/commit/91dfd4eecd
2023-12-01 15:17:20 +00:00
Martin Emde aac8be8034 [ruby/prism] Fix lex_compat for `<<HEREDOC # comment` at EOF
Fixes https://github.com/ruby/prism/pull/1874

https://github.com/ruby/prism/commit/304dd78dd2
2023-11-30 14:10:04 +00:00
TSUYUSATO Kitsune a908cef53f [ruby/prism] Reject class/module defs in method params/rescue/ensure/else
Fix https://github.com/ruby/prism/pull/1936

https://github.com/ruby/prism/commit/232e77a003
2023-11-29 02:03:06 +00:00
TSUYUSATO Kitsune c11dd34753 [ruby/prism] Reset `current_param_name` around closed scopes
It is for supporting `def foo(bar = (def baz(bar) = bar; 1)) = 2` case.

https://github.com/ruby/prism/commit/c789a833c5
2023-11-28 17:27:10 +00:00
TSUYUSATO Kitsune 9365b78d49 [ruby/prism] Fix to parse `*` as forwarding in `foo[*]` case
Fix https://github.com/ruby/prism/pull/1924

https://github.com/ruby/prism/commit/7cde900065
2023-11-28 13:25:59 +00:00
TSUYUSATO Kitsune 8654859dbd [ruby/prism] Fix and reuse pm_call_node_index_p
Fix https://github.com/ruby/prism/pull/1925
Fix https://github.com/ruby/prism/pull/1927

Previously pm_call_node_index_p does not check about a block argument
correctly and is not used in parse_write to check an index call node.

This commit fixes these problems.

https://github.com/ruby/prism/commit/92bab044ff
2023-11-27 17:33:31 +00:00
TSUYUSATO Kitsune 7b20dd9f91 [ruby/prism] Fix LocalVariableTargetNode depth in patterns
Fix https://github.com/ruby/prism/pull/1821

https://github.com/ruby/prism/commit/7d023a26b4
2023-11-23 14:39:30 +00:00
TSUYUSATO Kitsune 8794836bf2 [ruby/prism] Fix associativity of binary range with begin-less range
Fix https://github.com/ruby/prism/pull/1828

https://github.com/ruby/prism/commit/22c0640e48
2023-11-22 14:53:28 +00:00
TSUYUSATO Kitsune 154b2d666d [ruby/prism] Allow `&` forwarding in a method having `...` parameter
Fix https://github.com/ruby/prism/pull/1839

https://github.com/ruby/prism/commit/5784ab749f
2023-11-22 14:53:26 +00:00
Haldun Bayhantopcu f397650cda [ruby/prism] Fix lex_state_beg_p
(https://github.com/ruby/prism/pull/1591)

https://github.com/ruby/prism/commit/46b8576dd0
2023-11-21 17:22:18 +00:00
Kevin Newton e269096d15 [ruby/prism] Replace match write locals with match write targets
https://github.com/ruby/prism/commit/eec1862967
2023-11-20 18:00:44 -05:00
Hiroya Fujinami 8b4b0b7177 [ruby/prism] Don't add an invalid identifier capture to locals
(https://github.com/ruby/prism/pull/1836)

* Don't add an invalid identifier capture to locals

Fix https://github.com/ruby/prism/pull/1815

* Delay creating a MatchWriteNode

https://github.com/ruby/prism/pull/1836#discussion_r1393716600

https://github.com/ruby/prism/commit/635f595a36
2023-11-19 02:05:21 +00:00
Haldun Bayhantopcu e3f464522c [ruby/prism] Fix calls with splat without parenthesis
https://github.com/ruby/prism/commit/d81a77e0e3
2023-11-16 15:13:08 +00:00
TSUYUSATO Kitsune 64a122acfd [ruby/prism] Add test cases for `in` in `case` condition
Fix https://github.com/ruby/prism/pull/1515

It is also fixed by #1807, so this adds only test cases.

https://github.com/ruby/prism/commit/a0092f075e
2023-11-16 15:12:01 +00:00
Mike Dalessio d6d1a1839a [ruby/prism] fix: nested heredoc dedentation use-after-free
Because the lex mode may be freed when popped, we need to store off
this value for dedentation.

https://github.com/ruby/prism/commit/64007322f5

Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2023-11-14 14:11:55 +00:00
TSUYUSATO Kitsune 2fb1d37439 [ruby/prism] Reject invalid rational literals like `1e1r` on lexing
Fix https://github.com/ruby/prism/pull/1586

https://github.com/ruby/prism/commit/b3bde866f2
2023-11-12 02:34:02 +00:00
TSUYUSATO Kitsune cd91e8e73a [ruby/prism] Introduce non-associativility to `in` and `=>`
Fix https://github.com/ruby/prism/pull/1596
Fix https://github.com/ruby/prism/pull/1771
Close https://github.com/ruby/prism/pull/1773

https://github.com/ruby/prism/commit/a3413e5605
2023-11-11 20:37:28 +00:00
TSUYUSATO Kitsune fae44d6524 [ruby/prism] Reset do_loop_stack around a body of a endless method definition
Fix https://github.com/ruby/prism/pull/1772

https://github.com/ruby/prism/commit/cdf58e845e
2023-11-09 08:37:20 +00:00
Kevin Newton 8c0eb221b7 [ruby/prism] Forward parameters into arrays
https://github.com/ruby/prism/commit/2a11bfee76
2023-11-01 17:03:35 +00:00
Kevin Newton a8af5d3808 [ruby/prism] Use MatchWriteNode on split InterpolatedREN
https://github.com/ruby/prism/commit/ee54244800
2023-10-27 13:40:25 +00:00
Kevin Newton 82acca915a [ruby/prism] Ensure no extra multi-target nodes are created
https://github.com/ruby/prism/commit/ec31fd827f
2023-10-26 14:58:55 -04:00
Kevin Newton 8210cc4218 [ruby/prism] Fix lex compat when dedent should be 0
https://github.com/ruby/prism/commit/41c0e0e06e
2023-10-18 16:09:16 +00:00
Kevin Newton 9c973f9555 [ruby/prism] Use the unescaped regexp to scan for capture groups
https://github.com/ruby/prism/commit/555551e8f2
2023-10-18 14:23:46 +00:00
Kevin Newton 2a6f7cd925 [ruby/prism] Index{Operator,And,Or}WriteNode
Right now, our Call{Operator,And,Or}WriteNode nodes represent two
different concepts:

```ruby
foo.bar += 1
foo[bar] += 1
```

These two statements are different in what they can support. The
former can never have arguments (or an opening_loc or closing_loc).
The former can also never have a block. Also, the former is a
variable method name.

The latter is always going to be []/[]=, it can have any number of
arguments including blocks (`foo[&bar] ||= 1`), and will always
have an opening_loc and closing_loc.

Furthermore, these statements end of having to take different paths
through the various compilers because with the latter you have to
consider the arguments and the block, whereas the former can
perform some additional peephole optimizations since there are
fewer values on the stack.

For these reasons, I'm introducing Index{Operator,And,Or}WriteNode.
These nodes never have a read_name or write_name on them because
they are always []/[]=. They also support blocks, which the previous
write nodes didn't. As a benefit of introducing these nodes, I've
removed the opening_loc, closing_loc, and arguments from the older
write nodes because they will always be null.

For the serialized format, both of these nodes end up being
smaller, and for in-memory we're storing fewer things in general,
so we have savings all around.

I don't love that we are introducing another node that is a call
node since we generally want consumers to only have to handle a
single call, but these nodes are so specific that they would have
to be handled separately anyway since in fact call 2 methods.

https://github.com/ruby/prism/commit/70155db9cd
2023-10-18 14:23:26 +00:00
Kevin Newton 9bd99cc171 [ruby/prism] Fix up super with a blockarg
https://github.com/ruby/prism/commit/0ea19ed823
2023-10-17 00:42:31 +00:00
Kevin Newton 4f73a7c2f7 Sync to prism rename commits 2023-09-27 13:57:38 -04:00
Kevin Newton 8ab56869a6 Rename YARP filepaths to prism filepaths 2023-09-27 13:57:38 -04:00