| Age | Commit message (Collapse) | Author |
|
|
|
[ruby/prism] No writing to numbered parameters
Fixes [Bug #21117]
https://github.com/ruby/prism/commit/19d4bab5a0
|
|
Ruby feature: https://bugs.ruby-lang.org/issues/20952
https://github.com/ruby/prism/commit/e612df5f36
|
|
If we hit an EOF token, and the character before the EOF is a newline,
we should make EOF token start at the previous newline. That way any
errors reported will occur on that line.
For example "foo(\n" should report an error on line 1 even though the
EOF technically occurs on line 2.
[Bug #20918]
https://bugs.ruby-lang.org/issues/20918
https://github.com/ruby/prism/commit/60bc43de8e
|
|
https://github.com/ruby/prism/commit/280517c325
|
|
https://github.com/ruby/prism/commit/86cf82794a
|
|
https://github.com/ruby/prism/commit/fb7e1ebb7f
|
|
https://github.com/ruby/prism/commit/6b78f5309b
|
|
https://github.com/ruby/prism/commit/f59295938b
|
|
https://github.com/ruby/prism/commit/73669b59f6
|
|
https://bugs.ruby-lang.org/issues/20478
|
|
https://github.com/ruby/prism/commit/6f886be0a4
|
|
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
|
|
https://github.com/ruby/prism/commit/53bbcfe513
|
|
https://github.com/ruby/prism/commit/c386ba6d48
|
|
https://github.com/ruby/prism/commit/ab43b3ab66
|
|
https://github.com/ruby/prism/commit/178d4f66fd
|
|
https://github.com/ruby/prism/commit/863197629c
|
|
https://github.com/ruby/prism/commit/57d5c9be2c
|
|
https://github.com/ruby/prism/commit/dd532ded95
|
|
https://github.com/ruby/prism/commit/826657232e
|
|
https://github.com/ruby/prism/commit/c1b07ec11b
|
|
https://github.com/ruby/prism/commit/e950dc1e83
|
|
|
|
https://github.com/ruby/prism/commit/4e34f236d3
|
|
https://github.com/ruby/prism/commit/450541d2c3
|
|
https://github.com/ruby/prism/commit/3b1a99526a
|
|
https://github.com/ruby/prism/commit/d398e7d22c
|
|
https://github.com/ruby/prism/commit/9feeafbc67
|
|
https://github.com/ruby/prism/commit/8ee43be26d
|
|
https://github.com/ruby/prism/commit/8ce9ae487f
|
|
https://github.com/ruby/prism/commit/c739f8e194
|
|
https://github.com/ruby/prism/commit/6a15e475c9
|
|
https://github.com/ruby/prism/commit/2752f0b8df
|
|
https://github.com/ruby/prism/commit/9e200dd1c1
|
|
https://github.com/ruby/prism/commit/5f86742537
|
|
https://github.com/ruby/prism/commit/c0381b10e4
|
|
https://github.com/ruby/prism/commit/0cc3a9d63a
|
|
https://github.com/ruby/prism/commit/0d5a6d936a
|
|
check
https://github.com/ruby/prism/commit/ddec1c163d
|
|
https://github.com/ruby/prism/commit/71ea82f299
|
|
https://github.com/ruby/prism/commit/aa2182f064
|
|
|
|
`PM_ERR_RETURN_INVALID`
This PR fixes the following incorrect range of `Prism::Location` when `PM_ERR_RETURN_INVALID`.
It may be hard to tell from the text, but this Ruby error highlights `return`:
```console
$ ruby -e 'class Foo return end'
-e:1: Invalid return in class/module body
class Foo return end
-e: compile error (SyntaxError)
```
Previously, the error's `Prism::Location` pointed to `end`:
```console
$ bundle exec ruby -Ilib -rprism -ve 'p Prism.parse("class Foo return end").errors'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
[#<Prism::ParseError @type=:return_invalid @message="invalid `return` in a class or module body"
@location=#<Prism::Location @start_offset=17 @length=3 start_line=1> @level=:fatal>]
After this fix, it will indicate `return`.
```console
$ bundle exec ruby -Ilib -rprism -ve 'p Prism.parse("class Foo return end").errors'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
[#<Prism::ParseError @type=:return_invalid @message="invalid `return` in a class or module body"
@location=#<Prism::Location @start_offset=10 @length=6 start_line=1> @level=:fatal>]
```
For reference, here are the before and after of `Prism::Translation::Parser`.
Before:
```console
$ bundle exec ruby -Ilib -rprism -rprism/translation/parser33 -ve 'p Prism::Translation::Parser33.parse("class Foo return end")'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
(string):1:18: error: invalid `return` in a class or module body
(string):1: class Foo return end
(string):1: ^~~
/Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/parser-3.3.0.5/lib/parser/diagnostic/engine.rb:72:in `process':
invalid `return` in a class or module body (Parser::SyntaxError)
from /Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser.rb:220:in `block in unwrap'
from /Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser.rb:218:in `each'
from /Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser.rb:218:in `unwrap'
from /Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser.rb:49:in `parse'
from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/parser-3.3.0.5/lib/parser/base.rb:33:in `parse'
from -e:1:in `<main>'
```
After:
```console
$ bundle exec ruby -Ilib -rprism -rprism/translation/parser33 -ve 'p Prism::Translation::Parser33.parse("class Foo return end")'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
(string):1:11: error: invalid `return` in a class or module body
(string):1: class Foo return end
(string):1: ^~~~~~
/Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/parser-3.3.0.5/lib/parser/diagnostic/engine.rb:72:in `process':
invalid `return` in a class or module body (Parser::SyntaxError)
from /Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser.rb:220:in `block in unwrap'
from /Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser.rb:218:in `each'
from /Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser.rb:218:in `unwrap'
from /Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser.rb:49:in `parse'
from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/parser-3.3.0.5/lib/parser/base.rb:33:in `parse'
from -e:1:in `<main>'
```
This PR ensures that the originally intended `return` is highlighted as it should be.
https://github.com/ruby/prism/commit/1f9af4d2ad
|
|
Fixes https://github.com/ruby/prism/pull/2617.
There was an issue with the lexer as follows.
The following are valid regexp options:
```console
$ bundle exec ruby -Ilib -rprism -ve 'p Prism.lex("/x/io").value.map {|token| token[0].type }'
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75) [x86_64-darwin22]
[:REGEXP_BEGIN, :STRING_CONTENT, :REGEXP_END, :EOF]
```
The following are invalid regexp options. Unnecessary the `IDENTIFIER` token is appearing:
```console
$ bundle exec ruby -Ilib -rprism -ve 'p Prism.lex("/x/az").value.map {|token| token[0].type }'
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75) [x86_64-darwin22]
[:REGEXP_BEGIN, :STRING_CONTENT, :REGEXP_END, :IDENTIFIER, :EOF]
```
As a behavior of Ruby, when given `A` to `Z` and `a` to `z`, they act as invalid regexp options. e.g.,
```console
$ ruby -e '/regexp/az'
-e:1: unknown regexp options - az
/regexp/az
-e: compile error (SyntaxError)
```
Thus, it should probably not be construed as `IDENTIFIER` token.
Therefore, `pm_byte_table` has been adapted to accept those invalid regexp option values.
Whether it is a valid regexp option or not is checked by `pm_regular_expression_flags_create`.
For invalid regexp options, `PM_ERR_REGEXP_UNKNOWN_OPTIONS` is added to diagnostics.
https://github.com/ruby/prism/commit/d2a6096fcf
|
|
* Also add warnings for literals in predicates
* Also create flip-flops in while/until
https://github.com/ruby/prism/commit/a6b5c523c2
|
|
https://github.com/ruby/prism/commit/120d8c0479
|
|
https://github.com/ruby/prism/commit/ee87ed08fb
|
|
|
|
https://github.com/ruby/prism/commit/19ffa0b980
|