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

925 Коммитов

Автор SHA1 Сообщение Дата
Benoit Daloze d6764076a1 [ruby/prism] Review config.yml: documentation, types and field names
https://github.com/ruby/prism/commit/d43333539e
2024-08-28 17:42:56 +00:00
Kevin Newton ccef391140 [ruby/prism] Swap around order of predicates for assoc static literal
https://github.com/ruby/prism/commit/ec181a3b68
2024-08-28 15:35:23 +00:00
Kevin Newton 4c5a1dad0a [PRISM] Check length of line for shebang 2024-08-28 10:50:46 -04:00
eileencodes 2157dcb568 [ruby/prism] Add `contains_splat` flag
If we have a splat, add a flag for it named `contains_splat`.

https://github.com/ruby/prism/commit/5be97a75c8
2024-08-27 20:53:11 +00:00
eileencodes 7462cc7743 [PRISM] Fix allocations for keyword splat params
Fixes the following allocations tests:

* `test_keyword_and_keyword_splat_parameter`
* `test_keyword_parameter`
* `test_keyword_splat_parameter`
* `test_no_array_allocation_with_splat_and_nonstatic_keywords`
* `test_no_parameters`
* `test_positional_splat_and_keyword_splat_parameter`
* `test_ruby2_keywords`

* Checks for `first_chunk` and if `stack_length == 0` to match the
upstream parser. Otherwise, this optimization is skipped.
* Subtracts the index, otherwise it will skip the hash allocation for
the following: `keyword(*empty_array, a: 2, **empty_hash)`.
* Sets `dup_rest` in order to determine when to set the correct flags
* Doesn't set `VM_CALL_KW_SPLAT_MUT` flag unless `dup_rest` doesn't
match `initial_dup_rest`.

Given the following code:

```ruby
keyword(*empty_array, a: 2)
```

Instructions before:

```
== disasm: #<ISeq:test@test.rb:4 (4,0)-(8,3)>
local table (size: 2, argc: 1 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 2] empty_hash@0<Arg>[ 1] empty_array@1
0000 newarray                               0                         (   5)[LiCa]
0002 setlocal_WC_0                          empty_array@1
0004 putself                                                          (   7)[Li]
0005 getlocal_WC_0                          empty_array@1
0007 splatarray                             true
0009 putobject                              :a
0011 putobject                              2
0013 newhash                                2
0015 opt_send_without_block                 <calldata!mid:keyword, argc:2, ARGS_SPLAT|ARGS_SPLAT_MUT|FCALL|KW_SPLAT>
0017 leave                                                            (   8)[Re]
```

Instructions after:

```
== disasm: #<ISeq:test@test.rb:4 (4,0)-(8,3)>
local table (size: 2, argc: 1 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 2] empty_hash@0<Arg>[ 1] empty_array@1
0000 newarray                               0                         (   5)[LiCa]
0002 setlocal_WC_0                          empty_array@1
0004 putself                                                          (   7)[Li]
0005 getlocal_WC_0                          empty_array@1
0007 splatarray                             false
0009 putobject                              {:a=>2}
0011 opt_send_without_block                 <calldata!mid:keyword, argc:2, ARGS_SPLAT|FCALL|KW_SPLAT>
0013 leave                                                            (   8)[Re]
```

Differences:

* `splatarray` is `false` not `true
* `putobject`, `putobject`, `newhash` is simply `putobject` with
optimizations on
* Remove `ARGS_SPLAT_MUT` flag

Related: ruby/prism#2994

Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2024-08-27 16:01:46 -04:00
Alexander Momchilov 2fbaff5351 [ruby/prism] Fix warning when `#!` ends with carriage return
https://github.com/ruby/prism/commit/5753fb6260
2024-08-27 16:46:44 +00:00
Alexander Momchilov 83e72fde83 Optimize Array allocations
… by allocating them with the correct capacity.
2024-08-27 16:23:50 +00:00
Kevin Newton 4ede15fb53 [PRISM] Fix up nested string flags inside string concatenation 2024-08-26 10:49:35 -04:00
Alexander Momchilov 2b0b68fa46 Shrink `pm_integer_t` (32 bytes → 24) 2024-08-26 12:38:58 +00:00
Nobuyoshi Nakada 620ce3807b
[Bug #20680] `ensure` block is always void context 2024-08-25 08:16:54 +09:00
Kevin Newton 3eb42054d9 [ruby/prism] Pass Unicode escapes on to onigmo
When we encounter an invalid unicode escape within a regular
expression, we now pass that error on to Onigmo as if it didn't
exist in the parser (which matches the upstream parser's behavior).

We do this because there are tests that specify that you are
allowed to have invalid Unicode escapes if they are within the
context of a regular expression comment for a regular expression
in extended mode. That looks like:

    /# \u /x

Note that this _only_ applies to Unicode escapes (as opposed to
applying to hex or meta/control escapes as well). Importantly it
also only applies if the regular expression is terminated. An
unterminated regular expression will still get error handling done
in the parser. That would look like:

    /# \u

that would result in the same error handling we have today.

https://github.com/ruby/prism/commit/fb98034806
2024-08-23 19:18:14 +00:00
Kevin Newton 3f30c4df8c [ruby/prism] Update templates/include/prism/ast.h.erb
https://github.com/ruby/prism/commit/7f7620b6d5
2024-08-22 15:23:33 +00:00
Alexander Momchilov 0ef703b91c [ruby/prism] Render node comments into their `ast.h`
https://github.com/ruby/prism/commit/b17c3241d3
2024-08-22 15:23:32 +00:00
Kevin Newton d57486cb10 [ruby/prism] Turn off extended mode when parsing extended group
https://github.com/ruby/prism/commit/098b3f08bc
2024-08-22 14:43:35 +00:00
Kevin Newton 5cb6954baa [ruby/prism] Fix up lex result constants
https://github.com/ruby/prism/commit/084baca463
2024-08-15 16:50:00 +00:00
Kevin Newton cbf508da58 [ruby/prism] Special error for too short unicode errors
https://github.com/ruby/prism/commit/9f1f7d08bd
2024-08-15 16:40:05 +00:00
Kevin Newton a952ea243f [ruby/prism] Callback on shebang switches
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
2024-08-14 17:40:43 +00:00
Kevin Newton a6581114b0 [ruby/prism] Fix up spacing in generated node.rb
https://github.com/ruby/prism/commit/50d79b734b
2024-08-13 12:41:07 +00:00
Koichi ITO ad23bbe574 [ruby/prism] [Doc] Tweak the docs for lex APIs
`Prism.lex` and `Prism.lex_file` return `ParseLexResult` instead of `Array`.
`Prism::parse_lex` and `Prism::parse_lex_file` return `ParseLexResult` instead of `ParseResult`.
This PR updates the documentation to reflect these return values.

https://github.com/ruby/prism/commit/ee331941c0
2024-08-10 08:42:36 +00:00
Yuta Saito a65c205a1b [ruby/prism] Add explicit check for PRISM_HAS_NO_FILESYSTEM
https://github.com/ruby/prism/commit/89c22f0e6c
2024-07-26 17:07:50 +00:00
Yuta Saito 1992bd31a5 [ruby/prism] Fallback to pm_string_file_init on platforms without memory-mapped files
> ..., and on other POSIX systems we'll use `read`.

As `pm_string_mapped_init`'s doc comment says, it should fall back to
`read(2)`-based implementation on platforms without memory-mapped files
like WASI, but it didn't. This commit fixes it by calling `pm_string_file_init`
in the fallback case.
Also `defined(_POSIX_MAPPED_FILES)` check for `read(2)`-based path is
unnecessary, and it prevents the fallback from being executed, so this
change removes it.

https://github.com/ruby/prism/commit/b3d9064b71
2024-07-26 17:07:50 +00:00
Benoit Daloze 53f0d3b1f7 [ruby/prism] Do not serialize common flags when PRISM_SERIALIZE_ONLY_SEMANTICS_FIELDS is set
* Note that we could shift the flags by 2 on serialize & deserialize
  but it does not seems worth it as it does not save serialized size
  in any significant amount, i.e. average was 0.799 before #2924.
* $ bundle exec rake serialized_size:topgems
Before:
Total sizes for top 100 gems:
total source size:      90207647
total serialized size:  69477115
total serialized/total source: 0.770

Stats of ratio serialized/source per file:
average: 0.844
median:  0.825
1st quartile: 0.597
3rd quartile: 1.064
min - max: 0.078 - 3.792

After:
Total sizes for top 100 gems:
total source size:      90207647
total serialized size:  66150209
total serialized/total source: 0.733

Stats of ratio serialized/source per file:
average: 0.800
median:  0.779
1st quartile: 0.568
3rd quartile: 1.007
min - max: 0.076 - 3.675

https://github.com/ruby/prism/commit/e012072f70
2024-07-25 11:39:05 +00:00
Benoit Daloze 9cc2747ebb [ruby/prism] Do not serialize node_id when PRISM_SERIALIZE_ONLY_SEMANTICS_FIELDS is set
* $ bundle exec rake serialized_size:topgems
Before:
Total sizes for top 100 gems:
total source size:      90207647
total serialized size:  86284647
total serialized/total source: 0.957

Stats of ratio serialized/source per file:
average: 0.952
median:  0.937
1st quartile: 0.669
3rd quartile: 1.206
min - max: 0.080 - 4.065

After:
Total sizes for top 100 gems:
total source size:      90207647
total serialized size:  69477115
total serialized/total source: 0.770

Stats of ratio serialized/source per file:
average: 0.844
median:  0.825
1st quartile: 0.597
3rd quartile: 1.064
min - max: 0.078 - 3.792

https://github.com/ruby/prism/commit/cf90fe5759
2024-07-25 11:39:04 +00:00
Kevin Newton 575fe63e20 [ruby/prism] Inherit ractor state for child scopes
https://github.com/ruby/prism/commit/4576cb1d96
2024-07-24 16:24:21 +00:00
Nobuyoshi Nakada e642ddf7ae
[Bug #20647] Disallow `return` directly within a singleton class 2024-07-24 14:44:32 +09:00
Kevin Newton cb863907d8 [ruby/prism] Single line method bodies should not be marked as newline
https://github.com/ruby/prism/commit/18a8597276
2024-07-23 18:44:31 +00:00
Kevin Newton 744cf0549e [ruby/prism] Recurse upward to detect invalid returns
https://github.com/ruby/prism/commit/3d39b7961f
2024-07-23 14:54:01 +00:00
Kevin Newton 959c95a01e [ruby/prism] Ignore shebangs in evals
https://github.com/ruby/prism/commit/4c55409794
2024-07-22 19:46:26 +00:00
Kevin Newton 2effa98b6f [ruby/prism] Implement mismatched indentation warning
https://github.com/ruby/prism/commit/5d5bf92be8
2024-07-22 18:57:10 +00:00
Kevin Newton 1e4c4fe478 [ruby/prism] Fix parsing parentheses in hash patterns
https://github.com/ruby/prism/commit/22c3b559cd
2024-07-19 12:55:49 +00:00
Kevin Newton 059535bd65 [ruby/prism] Mark local variable writes in value positions as being read
https://github.com/ruby/prism/commit/f5149870ab
2024-07-18 19:38:53 +00:00
Kevin Newton 8e5ac5a87d [PRISM] Ensure not opening directories 2024-07-18 13:03:25 -04:00
Kevin Newton e77e4aa608 [ruby/prism] Have parse_stream handle NUL bytes
https://github.com/ruby/prism/commit/4a41d298c8
2024-07-17 19:44:32 +00:00
Koichi ITO 0fe816f380 [ruby/prism] [Doc] Tweak example of `Prism::Dispatcher`
This PR tweaked the documentation to correct an error encountered
when running the example code of `Prism::Dispatcher`.
This aims to make understanding the example smoother.

https://github.com/ruby/prism/commit/165a1a0e78
2024-07-17 18:17:59 +00:00
Nobuyoshi Nakada 644424941a [Bug #20457] [Prism] Remove redundant return flag 2024-07-17 14:06:11 -04:00
Kevin Newton c06f79c575 [ruby/prism] Fix up implicit flags
https://github.com/ruby/prism/commit/f4152c1f50
2024-07-15 18:12:37 +00:00
Kevin Newton 6298667ff5 [ruby/prism] When parsing an invalid write, still add to the local table
https://github.com/ruby/prism/commit/a54abc4d1b
2024-07-12 13:50:00 +00:00
Kevin Newton cfaa3e9311 [ruby/prism] Bump typecheck dependencies to fix CI
https://github.com/ruby/prism/commit/c7a4a90ee8
2024-07-11 19:46:51 +00:00
Kevin Newton ac093f5a06 [PRISM] Fix up shareable constant casting 2024-07-11 14:25:54 -04:00
Kevin Newton c1df15c3e6 [PRISM] Use node ids for error highlight 2024-07-11 14:25:54 -04:00
Stan Lo be4589df80 [ruby/prism] Prevent optional block parameter from accepting certain prefixed values
This commit prevents the following unary operators from being accepted
as the value prefix of a block's optional parameter:

- `+`
- `-`
- `~`
- `!`

For example, `f { |a = +b| }` will now raise a syntax error.

https://github.com/ruby/prism/commit/3024bee60c

Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2024-07-11 14:25:54 -04:00
Kevin Newton aa473489a2 [ruby/prism] Various cleanup for initializers and typechecks
https://github.com/ruby/prism/commit/86cf82794a
2024-07-11 14:25:54 -04:00
Kevin Newton 2bf9ae3fa1 [ruby/prism] Add node ids to nodes
https://github.com/ruby/prism/commit/bf16ade7f9
2024-07-11 14:25:54 -04:00
Kevin Newton 39dcfe26ee [ruby/prism] Move Node#type and Node::type documentation
https://github.com/ruby/prism/commit/08a71f6259
2024-07-11 14:25:54 -04:00
Kevin Newton 32090e2b8d [ruby/prism] Add Node#breadth_first_search
https://github.com/ruby/prism/commit/1ffb141199
2024-07-11 14:25:54 -04:00
Kevin Newton aca42a2478 [ruby/prism] Expose common flags in inspect output
https://github.com/ruby/prism/commit/d0143865c2
2024-07-11 14:25:54 -04:00
Kevin Newton 687be43c79 [ruby/prism] Expose flags on every node type
https://github.com/ruby/prism/commit/9f12a56fd6
2024-07-11 14:25:54 -04:00
Kevin Newton ca48fb76fb [ruby/prism] Move location to second position for node initializers
https://github.com/ruby/prism/commit/4cc0eda4ca
2024-07-11 14:25:54 -04:00
Kevin Newton 0ac9c6dc10 [ruby/prism] Fix up find and array patterns with multiple rests
https://github.com/ruby/prism/commit/035890a839
2024-07-01 15:22:40 +00:00
Kevin Newton 8fb2227205 [ruby/prism] Properly support parsing regexp in extended mode
https://github.com/ruby/prism/commit/bedc4585ed
2024-07-01 14:42:10 +00:00
Kevin Newton ce7299d09a [ruby/prism] Handle block exits under modifiers
https://github.com/ruby/prism/commit/6b78f5309b
2024-06-26 20:46:27 +00:00
Andrew Konchin a47c152ab5 [ruby/prism] Fix documentation comment in generated with templates files
Fix warning
```
/******************************************************************************/
^
warning: [dangling-doc-comments] documentation comment is not attached to any declaration

```
in Nodes.java and AbstractNodeVisitor.java files. /** is treated as a starting of a javadoc comment.

https://github.com/ruby/prism/commit/c83d7844b8
2024-06-25 20:15:25 +00:00
Yusuke Endoh 9a22d4b9a0 [ruby/prism] Update `#line` that was missed to update
Follow up https://github.com/ruby/prism/commit/1a2626be275d

https://github.com/ruby/prism/commit/8174aac929
2024-06-21 12:32:04 +00:00
Yusuke Endoh c3b5b98e15 [ruby/prism] Set `#line" directives to respect the path in ruby/ruby repo
ruby/ruby measures test coverage of C code, but the `#line` directive
generated by prism points to a file that does not exist, so coverage is
not taken properly.

This changeset specifies the location of the source files as a relative
path in terms of ruby/ruby repo.

https://github.com/ruby/prism/commit/1a2626be27
2024-06-20 12:36:18 +00:00
Kevin Newton c93b70cfdd [ruby/prism] Make sure Init_prism is visible for extension
https://github.com/ruby/prism/commit/4601d3adfd
2024-06-19 00:06:01 +00:00
Herwin 84947c515a [ruby/prism] Document MultiWriteNode fields
https://github.com/ruby/prism/commit/b6a97a43c2
2024-06-15 15:03:18 +00:00
Herwin 6184882b84 [ruby/prism] Document MultiTargetNode
https://github.com/ruby/prism/commit/b817cd25c5
2024-06-15 12:06:49 +00:00
Kevin Newton 7529591df1 [ruby/prism] Ensure ranges are non-associative
https://github.com/ruby/prism/commit/f59295938b
2024-06-14 19:22:54 +00:00
Kevin Newton 0321f2c8fe [ruby/prism] Handle implicit array precedence
When an implicit array is used in a write, is causes the whole
expression to become a statement. For example:

```ruby
a = *b
a = 1, 2, 3
```

Even though these expressions are exactly equivalent to their
explicit array counterparts:

```ruby
a = [*b]
a = [1, 2, 3]
```

As such, these expressions cannot be joined with other expressions
by operators or modifiers except if, unless, while, until, or
rescue.

https://github.com/ruby/prism/commit/7cd2407272
2024-06-13 18:46:02 +00:00
Kevin Newton 47322b592a [ruby/prism] Match CRuby error message for unknown regexp options
https://github.com/ruby/prism/commit/73669b59f6
2024-06-11 12:34:00 +00:00
Kevin Newton d6b1822f22 [ruby/prism] Fix binding power for class <<
https://github.com/ruby/prism/commit/cd66c478de
2024-06-11 12:33:46 +00:00
Kevin Newton d827d32527 [ruby/prism] Provide ability to lock encoding while parsing
https://github.com/ruby/prism/commit/f7faedfb3f
2024-06-10 17:21:32 -04:00
Kevin Newton 0d5eea9957 [ruby/prism] Disallow multi writes when not in statement level
https://github.com/ruby/prism/commit/fe34a77df2
2024-06-10 17:21:32 -04:00
Kevin Newton 21e06e57af [ruby/prism] Allow block exits in loop predicates
https://github.com/ruby/prism/commit/f09db18e46
2024-06-10 13:42:40 +00:00
Nobuyoshi Nakada c357138aa3
Use `PRISM_EXPORTED_FUNCTION` consistently with the header 2024-06-09 17:34:37 +09:00
Kevin Newton c90b5303a2
Sync prism version to latest 2024-06-07 15:54:06 -04:00
Kevin Newton cbc83c4a92 Remove circular parameter syntax error
https://bugs.ruby-lang.org/issues/20478
2024-06-06 16:29:50 -04:00
Kevin Newton 7b7d1586ee [ruby/prism] Reject additional patterns under splat in target
https://github.com/ruby/prism/commit/90d570aa50
2024-06-06 16:44:43 +00:00
Kevin Newton 6f3c1e1def [PRISM] Sync latest prism 2024-06-05 20:04:12 -04:00
Kevin Newton 46c3e609a3 [ruby/prism] Fix up documentation for regexp structs
https://github.com/ruby/prism/commit/78d9f20e9d
2024-06-05 14:40:03 -04:00
Kevin Newton d13112b779 [ruby/prism] Parse all regular expressions
https://github.com/ruby/prism/commit/11e0e204ce
2024-06-05 14:40:03 -04:00
Kevin Newton 2a9c20c317 [ruby/prism] Add Onigmo errors for invalid groups
https://github.com/ruby/prism/commit/27e7685dd4
2024-06-05 14:40:03 -04:00
Kevin Newton 0406efaf05 [ruby/prism] Add Onigmo error for invalid repeat and empty group name
https://github.com/ruby/prism/commit/953601e3c0
2024-06-05 14:40:03 -04:00
Kevin Newton d604287626 [ruby/prism] Add Onigmo error for empty char-class
https://github.com/ruby/prism/commit/2e02fa3b80
2024-06-05 14:40:03 -04:00
Kevin Newton c3747d5a2e [ruby/prism] Report onigmo errors for depth
https://github.com/ruby/prism/commit/e0e8bba8be
2024-06-05 14:40:03 -04:00
Kevin Newton 41f2734644 [ruby/prism] Change pm_regexp_parse to not return boolean
https://github.com/ruby/prism/commit/b03afbe857
2024-06-05 14:40:03 -04:00
Kevin Newton 65746055b4 [ruby/prism] Pass prism parser into regexp parser
https://github.com/ruby/prism/commit/c19b0fa185
2024-06-05 14:40:03 -04:00
Kevin Newton ac70dd07e6 [ruby/prism] Remove unused string list struct
https://github.com/ruby/prism/commit/36c6851c85
2024-06-05 14:40:03 -04:00
Kevin Newton ad438623e8 [ruby/prism] Switch regexp parsing to use a callback from named capture groups
https://github.com/ruby/prism/commit/29d80e486e
2024-06-05 14:40:03 -04:00
Jeremy Evans 89486c79bb
Make error messages clear blocks/keywords are disallowed in index assignment
Blocks and keywords are allowed in regular index.

Also update NEWS to make this more clear.

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2024-05-31 08:22:40 -07:00
nasa af89465406 [ruby/prism] Document `ForNode` fields
(https://github.com/ruby/prism/pull/2845)

* Add document

* fix

* fix fmt

* fix fmt

* Revert "fix fmt"

This reverts commit https://github.com/ruby/prism/commit/b23a05a94148.

* add potition

* fix fmt

* reposition

* fix indent

* fix comment

* fix indent

https://github.com/ruby/prism/commit/0dd4c1bba1
2024-05-29 13:36:10 +00:00
Kevin Newton 7f18126882 [ruby/prism] Fix line continuation heredoc dedent calculation
https://github.com/ruby/prism/commit/63b596df07
2024-05-28 16:31:55 +00:00
Herwin 61e2916d1c [ruby/prism] Typo fix: poitive => positive
https://github.com/ruby/prism/commit/d13a05252d
2024-05-28 15:28:02 +00:00
Kevin Newton 9f71393fe4 [ruby/prism] Fix up self-write order for lex
https://github.com/ruby/prism/commit/8f6da451b4
2024-05-24 17:37:51 +00:00
Kevin Newton 745a948b6d [ruby/prism] Remove dynamic Debug module methods
https://github.com/ruby/prism/commit/b850794db9
2024-05-24 17:19:36 +00:00
Kevin Newton 79001c8b4a [ruby/prism] Remove error formatting, put directly in CRuby
https://github.com/ruby/prism/commit/53b2866487
2024-05-24 17:19:36 +00:00
Kevin Newton 653652bcbe [ruby/prism] Remove Debug#named_captures
https://github.com/ruby/prism/commit/5050dfbe70
2024-05-24 17:19:35 +00:00
Kevin Newton e1041a8eda [ruby/prism] Move profiling to prism module directly
https://github.com/ruby/prism/commit/75fabf7081
2024-05-24 17:19:35 +00:00
Kevin Newton b04c959621 [ruby/prism] Remove various unused memsize infra
https://github.com/ruby/prism/commit/283938ed1f
2024-05-24 17:19:34 +00:00
Kevin Newton b8681c2e37 [ruby/prism] Remove Debug::integer_parse
https://github.com/ruby/prism/commit/14e397598b
2024-05-24 17:19:33 +00:00
Kevin Newton 870350253e [ruby/prism] Remove Debug::static_inspect
https://github.com/ruby/prism/commit/486c71c426
2024-05-24 17:19:33 +00:00
Kevin Newton 7021e15652 [ruby/prism] Update duplicated when error message
https://github.com/ruby/prism/commit/54316fd8a0
2024-05-24 12:36:54 -04:00
eileencodes c96b5791ef [ruby/prism] Raise `void value expression` in begin clauses
In some cases Prism was either not raising an appropriate `void value
expression` error, or raising that error when the syntax is considered
valid.

To fix this Prism needs to check whether we have other clauses on the
`begin` rather than just returning `cast->statements`.

* If the `cast->statements` are null and the `cast->ensure_clause` is
not null, set the code to `cast->ensure_clause`
* else
  * If there is a `cast->rescue_clause`
    * Check if `cast->statements` are null and `cast->rescue_clause->statements`
    are null, and return `NULL`
    * Check if there is an `else_clause`, and set the node to
      `cast->else_clause`.
    * Otherwise return `cast->statements` as the node
  * return `cast->statements` as the node

See tests for test cases. Note I took these directly from CRuby so if
desired I can delete them since the test will now pass. This only fixes
one test in the `test_parse` file, taking failures from 14 to 13.

This fixes `TestParse#test_void_value_in_rhs` and is related to
issue #2791.

https://github.com/ruby/prism/commit/398152b412
2024-05-23 19:30:03 +00:00
Kevin Newton e5e079e70f [ruby/prism] Only accept command call when specified for constant path
https://github.com/ruby/prism/commit/0ae908b6ee
2024-05-23 18:45:04 +00:00
Kevin Newton 7d89d52714 [ruby/prism] Disallow newlines in heredoc identifiers
https://github.com/ruby/prism/commit/737f2c2117
2024-05-23 15:51:27 +00:00
Kevin Newton 6d81ae3f01 [PRISM] Properly support 'it' 2024-05-22 16:34:04 -04:00
Kevin Newton e575954887 [ruby/prism] Fix support for 'it' implicit local variable
https://github.com/ruby/prism/commit/53bbcfe513
2024-05-22 16:34:04 -04:00
Kevin Newton 89efb94fec [ruby/prism] Reconfigure rationals
This eliminates the subnode on RationalNode and replaces it with two
integer fields, which represent the ratio for the rational. It also
reduces those two integers if they both fit into 32 bits.

Importantly, this PR does not implement bignum reduction. That's something
I'd like to consider for the future, but it's simple enough for now to
leave them unreduced, which makes it more useful than it used to be.

https://github.com/ruby/prism/commit/86e06c7068
2024-05-21 14:27:46 -04:00
Kevin Newton ff43b4a28b [ruby/prism] Add error for numbered parameter used in inner block
https://github.com/ruby/prism/commit/c386ba6d48
2024-05-21 15:46:45 +00:00
Kevin Newton 7c2c528d35 [ruby/prism] Fix up regexp escapes with control/meta
https://github.com/ruby/prism/commit/8a7afa6988
2024-05-20 19:39:21 +00:00