Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRuby tests/specs passing #2791

Open
10 tasks
kddnewton opened this issue May 8, 2024 · 0 comments
Open
10 tasks

CRuby tests/specs passing #2791

kddnewton opened this issue May 8, 2024 · 0 comments
Labels
bug Something isn't working compiler

Comments

@kddnewton
Copy link
Collaborator

kddnewton commented May 8, 2024

Changes needed

Pending response

@kddnewton kddnewton added this to the CRuby unblocked milestone May 8, 2024
@kddnewton kddnewton changed the title CRuby make test-all RUN_OPTS="--parser=prism" passing CRuby tests/specs passing May 8, 2024
@kddnewton kddnewton added bug Something isn't working compiler labels May 8, 2024
@kddnewton kddnewton pinned this issue May 8, 2024
eileencodes added a commit to eileencodes/prism that referenced this issue May 13, 2024
With the following statement:

```ruby
x = begin ensure return end
```

Prism wasn't raising the appropriate `void value expression` error. In
this code example, the `cast->statements` will be NULL. To get the
appropriate behavior and raise the error, the node needs to be assigned
to `cast->ensure_node->statements`. Otherwise no error is raised.

Note: this is related to ruby#2791 but doesn't fix the failures in
`test/ruby/test_parse.rb` because the format is different. But before we
can fix that, it needs to raise an error.
eileencodes added a commit to eileencodes/prism that referenced this issue May 14, 2024
With the following statement:

```ruby
x = begin ensure return end
```

Prism wasn't raising the appropriate `void value expression` error. In
this code example, the `cast->statements` will be NULL. To get the
appropriate behavior and raise the error, the node needs to be assigned
to `cast->ensure_node->statements`. Otherwise no error is raised.

Note: this is related to ruby#2791 but doesn't fix the failures in
`test/ruby/test_parse.rb` because the format is different. But before we
can fix that, it needs to raise an error.
eileencodes added a commit to eileencodes/prism that referenced this issue May 15, 2024
Prism wasn't raising the appropriate `void value expression` error. In
this code example, the `cast->statements` will be NULL. To get the
appropriate behavior and raise the error, the node needs to be assigned
to `cast->ensure_node->statements`. Otherwise no error is raised.

This fixes the following code:

```ruby
x = begin ensure return end
```

In addition, Prism was raising for code that is valid. The begin value
expression check also needs to take rescue clauses into account. If the
rescue clause has an else, we want to use the `statements` from that
node, otherwise we should use the `statements` from the `rescue` clause.

This fixes the following code (which should not throw a syntax error):

```ruby
x = begin return; rescue; end
x = begin return; rescue; return; else end
```

This fixes `TestParse#test_void_value_in_rhs` and is related to
issue ruby#2791.
eileencodes added a commit to eileencodes/prism that referenced this issue May 15, 2024
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, I'm checking whether the `begin` node has an `else_clause`,
`rescue_clause`, or `ensure_clause` and setting the returned `node` to
that instead of always returning `cast->statements`. In the
`ensure_clause` case, the `ensure_clause` node should only be used if
`statements` is `NULL`.  `rescue_clause` and `else_clause` should be
used regardless of whether `statements is `NULL`.

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 testin the `test_parse` file, taking failures from 14 to 13.

This fixes `TestParse#test_void_value_in_rhs` and is related to
issue ruby#2791.
eileencodes added a commit to eileencodes/prism that referenced this issue May 23, 2024
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, I'm checking whether the `begin` node has an `else_clause`,
`rescue_clause`, or `ensure_clause` and setting the returned `node` to
that instead of always returning `cast->statements`. In the
`ensure_clause` case, the `ensure_clause` node should only be used if
`statements` is `NULL`.  `rescue_clause` and `else_clause` should be
used regardless of whether `statements is `NULL`.

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 testin the `test_parse` file, taking failures from 14 to 13.

This fixes `TestParse#test_void_value_in_rhs` and is related to
issue ruby#2791.
eileencodes added a commit to eileencodes/prism that referenced this issue May 23, 2024
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 ruby#2791.
eileencodes added a commit to eileencodes/prism that referenced this issue May 23, 2024
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 ruby#2791.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler
Projects
None yet
Development

No branches or pull requests

1 participant