diff options
author | eileencodes <eileencodes@gmail.com> | 2024-05-13 17:10:22 -0400 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2024-05-23 19:30:03 +0000 |
commit | c96b5791efd7d14c7387adea9c6c252d7ecbb231 (patch) | |
tree | e75b890bb2868f24f8be5456cb7070fd7421188c /test/prism/snapshots/yield.txt | |
parent | 49fcd33e136ee2fe8720183b63a41bb6ef8d615c (diff) |
[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
Diffstat (limited to 'test/prism/snapshots/yield.txt')
0 files changed, 0 insertions, 0 deletions