summaryrefslogtreecommitdiff
path: root/test/prism
AgeCommit message (Collapse)Author
66 min.Reapply "[ruby/prism] Add Ripper :on_sp events for Prism.lex_compat and ↵Earlopain
Prism::Translation::Ripper" This reverts commit 58f1127b51cf4fbb1f334f8701a041f40701dca2.
4 hoursRevert "[ruby/prism] Add Ripper :on_sp events for Prism.lex_compat and ↵Hiroshi SHIBATA
Prism::Translation::Ripper" This reverts commit 35a7b5159f39de2cac848c072674e5350cc41aa4. This broke syntax_suggest. https://github.com/ruby/ruby/actions/runs/21167011751/job/60874111912
5 hours[ruby/prism] Add Ripper :on_sp events for Prism.lex_compat and ↵Benoit Daloze
Prism::Translation::Ripper * Handle line continuations. * Handle space at the end of file in LexCompat. https://github.com/ruby/prism/commit/32bd13eb7d Co-authored-by: Earlopain <14981592+Earlopain@users.noreply.github.com>
26 hours[ruby/prism] Add Prism::Source#line_to_byte_offset and replace direct ↵Benoit Daloze
accesses to offsets https://github.com/ruby/prism/commit/ff81a29ba5
31 hours[ruby/prism] Remove duplicate lex testsEarlopain
`RipperTest` already does this (added in https://github.com/ruby/prism/pull/3849) Since it doesn't use the token classes, it also lists out all the excludes instead of just claiming some are passing. https://github.com/ruby/prism/commit/e86a28263c
2 days[ruby/prism] Fix ripper translator for `__END__`Earlopain
https://github.com/ruby/prism/commit/2792ac78ca
4 days[ruby/prism] Make the ripper shim work with rdocEarlopain
The filter class is a 1:1 copy of ruby. rdoc has 32 test failures. It seems to expect `on_sp` in some cases to render code as written. https://github.com/ruby/prism/commit/74bb12c825
4 days[ruby/prism] Add `Ripper.tokenize` to translation layerEarlopain
It's public API and trivial to implement. https://github.com/ruby/prism/commit/e77545f8b5
5 days[ruby/prism] Fix locations for invalid syntax when using `expect1_opening`Earlopain
Followup to https://github.com/ruby/prism/pull/3827 It sets the start to the opening but it should instead just continue on as usual. Fixes https://github.com/ruby/prism/issues/3851 Notice how the AST actually contains "123" in both the body and end keyword. https://github.com/ruby/prism/commit/8f69c5af08
5 days[ruby/prism] Make irb work with the ripper shimEarlopain
This is everything that `irb` uses. It works in their test-suite, but there are 20 failures when using the shim that I haven't looked into at all. `parse` is not used by `irb`. `scan` is, and it's basically `parse` but also including errors. `irb` doesn't seem to care about the errors, so I didn't implement that. https://github.com/ruby/prism/commit/2c5826b39f
8 days[ruby/prism] Correctly expose ripper stateEarlopain
It is for example used by `irb`, `rdoc`, `syntax_suggest` https://github.com/ruby/prism/commit/255aeb2485
8 days[ruby/prism] Use one file for versioned `parser` classesEarlopain
One per version seems excessive. Do note that `rubocop-ast` used to require individual parser files. I wouldn't consider that to be part of the API since everything is autoloaded. From a GitHub code search, I didn't find anyone else doing it like that. https://github.com/ruby/prism/commit/458f622c34
9 days[ruby/prism] [Bug #21831] Fix denominator of rational float literalNobuyoshi Nakada
Denominators can contain underscores in fraction part as well as other numeric literals. [Bug #21831]: https://bugs.ruby-lang.org/issues/21831 https://github.com/ruby/prism/commit/e247cb58c7
12 days[ruby/prism] Decouple ripper translator from ripper libraryEarlopain
Ripper exposes Ripper::Lexer:State in its output, which is a bit of a problem. To make this work, I basically copy-pasted the implementation. I'm unsure if that is acceptable and added a test to make sure that these values never go out of sync. I don't imagine them changing often, prism maps them 1:1 for its own usage. This also fixed the shim by accident. `Ripper.lex` went to `Translation::Ripper.lex` when it should have been the original. Removing the need for the original resolves that issue. https://github.com/ruby/prism/commit/2c0bea076d
12 days[ruby/prism] Remove unneeded `ripper` requiresEarlopain
Ripper is either not used or loaded where it is actually needed https://github.com/ruby/prism/commit/a73a4fb00c
2025-12-29[ruby/prism] Report missing end errors at opening tokenThomas Marshall
This commit adds an `expect1_opening` function that expects a token and attaches the error to the opening token location rather than the current position. This is useful for errors about missing closing tokens, where we want to point to the line with the opening token rather than the end of the file. For example: ```ruby def foo def bar def baz ^ expected an `end` to close the `def` statement ^ expected an `end` to close the `def` statement ^ expected an `end` to close the `def` statement ``` This would previously produce three identical errors at the end of the file. After this commit, they would be reported at the opening token location: ```ruby def foo ^~~ expected an `end` to close the `def` statement def bar ^~~ expected an `end` to close the `def` statement def baz ^~~ expected an `end` to close the `def` statement ``` I considered using the end of the line where the opening token is located, but in some cases that would be less useful than the opening token location itself. For example: ```ruby def foo def bar def baz ``` Here the end of the line where the opening token is located would be the same for each of the unclosed `def` nodes. https://github.com/ruby/prism/commit/2d7829f060
2025-12-29[ruby/prism] Add unterminated construct testsThomas Marshall
https://github.com/ruby/prism/commit/166764f794
2025-12-18[ruby/prism] Reject `p(p a, &block => value)` and similarEarlopain
Redo of https://github.com/ruby/prism/pull/3669 with more tests https://github.com/ruby/prism/commit/48b403ea79
2025-12-18[ruby/prism] Add Ruby 4.1 as a version specifierEarlopain
https://github.com/ruby/prism/commit/138db9ccc4
2025-12-18[ruby/prism] Fix assertions in location_test.rbBenoit Daloze
* assert_raise's 2nd argument is the failure message, shown when the expected exception is not raised. It's not the expected message. See https://github.com/test-unit/test-unit/issues/347 https://github.com/ruby/prism/commit/e3df994d47
2025-12-04[ruby/prism] Fix `%Q` with newline delimiter and heredoc interpolationEarlopain
The lexer did not jump to the `heredoc_end`, causing the heredoc end delimiter to be parsed twice. Normally the heredocs get flushed when a newline is encountered. But because the newline is part of the string delimiter, that codepath is not taken. Fixes [Bug #21758] https://github.com/ruby/prism/commit/7440eb4b11
2025-12-02[ruby/prism] Clean up test excludesEarlopain
Mostly not having to list version-specific excludes when testing against ripper/parse.y Also don't test new syntax additions against the parser gems. The version support for them may (or may not) be expanded but we shouldn't bother while the ruby version hasn't even released yet. (ruby_parser translation is not versioned, so let as is for now) I also removed excludes that have since been implemented by parse.y https://github.com/ruby/prism/commit/e5a0221c37
2025-11-30[ruby/prism] Update unicode tables to match that of CRubyKevin Newton
The unicode version has been updated upstream, which means new codepoints mapped to alpha/alnum/isupper flags. We need to update our tables to match. I'm purposefully not adding a version check here, since that is such a large amount of code. It's possible that we could include different tables depending on a macro (like UNICODE_VERSION) or something to that effect, but it's such a minimal impact on the running of the actual parser that I don't think it's necessary. https://github.com/ruby/prism/commit/78925fe5b6
2025-11-30[ruby/prism] Fully destroy call operator write argumentsKevin Newton
If we are about to delete a call operator write argument, it needs to be removed from the list of block exits as well. https://github.com/ruby/prism/commit/ebc91c2e39
2025-11-29[ruby/prism] Fix label interpolated stringKevin Newton
https://github.com/ruby/prism/commit/e3e2b1ed04
2025-11-29[ruby/prism] Handle invalid string pattern keyKevin Newton
When a pattern match is using a string as a hash pattern key and is using it incorrectly, we were previously assuming it was a symbol. In the case of an error, that's not the case. So we need to add a missing node in this case. https://github.com/ruby/prism/commit/f0b06d6269
2025-11-23[ruby/prism] Revert "Reject `p(p a, &block => value)` and similar"Kevin Newton
https://github.com/ruby/prism/commit/fef2c20777
2025-11-23[ruby/prism] Reject `p(p a, &block => value)` and similarEarlopain
They were being parsed as `p((p a, &block) => value)`. When we get to this point, we must not just have parsed a command call, always consuming the `=>` is not correct. Closes [Bug #21622] https://github.com/ruby/prism/commit/796ab0edf4
2025-11-20[ruby/prism] Add tests to `regexp_encoding_option_mismatch`Thiago Araujo
related to #2667 https://github.com/ruby/prism/commit/44f075bae4
2025-11-17[ruby/prism] Remove now obsolete todosEarlopain
https://github.com/ruby/prism/commit/b00d098f9a
2025-11-16Handle deeply nested capture variables syntax errKevin Newton
When there are nested capture variables inside of a pattern match that has an alternation pattern, it is a syntax error. Currently it only adds a syntax error when it is at the top level of the pattern.
2025-11-14[ruby/prism] Reject endless method as a block parameter defaultEarlopain
Fixes [Bug #21661] https://github.com/ruby/prism/commit/475fa46a82
2025-11-14[Feature #21572] Syntax error at capture in alternation patternNobuyoshi Nakada
Should fail even with `-c` option.
2025-11-08[ruby/prism] Rename Ruby 3.5 to Ruby 4.0Earlopain
See https://github.com/ruby/ruby/commit/6d81969b475262aba251e99b518181bdf7c5a523 It leaves the old variant around. RuboCop for examples accesses `Prism::Translation::Parser35` to test against ruby-head. For now I left these simply as an alias https://github.com/ruby/prism/commit/d0a823f045
2025-11-07Prism update for 4.0Nobuyoshi Nakada
2025-11-06[ruby/prism] Reject `def f a, (b) = 1`Earlopain
Fixes [#Bug 21660], followup to https://github.com/ruby/prism/pull/3674 https://github.com/ruby/prism/commit/fb445a49e5 Co-Authored-By: tomoya ishida <tomoyapenguin@gmail.com>
2025-10-30[ruby/prism] Unescape unary method callsEarlopain
Followup to https://github.com/ruby/prism/pull/2213 Before: ```sh $ ruby -ve "puts 42.~@" ruby 3.4.6 (2025-09-16 revision https://github.com/ruby/prism/commit/dbd83256b1) +PRISM [x86_64-linux] -e:1:in '<main>': undefined method '~@' for an instance of Integer (NoMethodError) Did you mean? ~ ``` After (matches parse.y): ```sh $ ./miniruby -ve "puts 42.~@" ruby 3.5.0dev (2025-10-16T03:40:45Z master https://github.com/ruby/prism/commit/1d95d75c3f) +PRISM [x86_64-linux] -43 ``` https://github.com/ruby/prism/commit/a755bf228f
2025-10-22[ruby/prism] Test against parse.yEarlopain
https://github.com/ruby/prism/commit/17a6a19bbae5c8b438a94816ed67c3852547d859 broke ruby/ruby CI because some tests are only run against parse.y This will catch that in the future. https://github.com/ruby/prism/commit/98e1cd5c04
2025-10-22[ruby/prism] Make error and snapshot tests multi-version awareEarlopain
This one has been on my mind for a while now. Currently, there are only tests against the latest syntax version. This changes the snapshot structure as follows: * Snapshots at their current location are tested against all syntax versions * Snapshots inside a version folder like "3.3" are tested against all versions starting from that version * Snapshots inside a version folder like "3.3-4.2" are tested against all versions in the given range. This makes sure that as new syntax is added, older versions still work as expected. I also added a few tests for now valid syntax that should be invalid in older versions (and the other way around as well) These tests run really fast. So even though it does 3x the work for these, I am still able to run the whole test suite in just 11 seconds. https://github.com/ruby/prism/commit/5191b1aa68
2025-10-16[ruby/prism] Do not rely on RUBY_VERSION being consistentKevin Newton
https://github.com/ruby/prism/commit/34428946db
2025-10-16[ruby/prism] Do not stub Ruby versionKevin Newton
https://github.com/ruby/prism/commit/44c4306247
2025-10-16[ruby/prism] Add support for `Prism.parse(foo, version: "current")`Earlopain
The docs currently say to use `Prism.parse(foo, version: RUBY_VERSION)` for this. By specifying "current" instead, we can have prism raise a more specifc error. Note: Does not use `ruby_version` from `ruby/version.h` because writing a test for that is not really possible. `RUBY_VERSION` is nicely stubbable for both the c-ext and FFI backend. https://github.com/ruby/prism/commit/9c5cd205cf
2025-10-08[ruby/prism] For these special cases, there exists no optional argument ↵Earlopain
type. Since a endless method is started with `=`, there was ambiguity here. We have to simply reject these in all cases. This adds a new error for the following reason: * `def foo arg = nil` is interpreted as a normal method call with optional `arg` without matching `end` * `def foo *arg = nil; end` is interpreted as a endless method call that has body `nil` with extraneous `end` `def foo *arg = nil` is somewhere inbetween and I don't know how to otherwise indicate the error. Now the second case above also shows the newly added error message. Fixes [Bug #21623] https://github.com/ruby/prism/commit/e1910d4492
2025-10-06Sync Prism (#14751)Takashi Kokubun
to https://github.com/ruby/prism/commit/c89ca2af12ba20b4fd2c5ff43ebe25da1d81d8db
2025-09-19[ruby/prism] Fix up locals test skip nameKevin Newton
https://github.com/ruby/prism/commit/d1b22f59a0
2025-09-19[ruby/prism] Turn off failing test for parse.yKevin Newton
https://github.com/ruby/prism/commit/cb27f5a70a
2025-09-19[ruby/prism] Reject argument command call taking a block with more trailing ↵Earlopain
arguments https://bugs.ruby-lang.org/issues/21168#note-5 The added code samples align with `parse.y`, except for `foo(bar baz do end)` which `parse.y` currently rejects but shouldn't. https://github.com/ruby/prism/commit/3a4e102d80
2025-09-17[ruby/prism] Reject `1 if foo = bar baz`Earlopain
and also `1 and foo = bar baz` This is a partial fix for https://github.com/ruby/prism/issues/3106 It still accepts `a = b c and 1` https://github.com/ruby/prism/commit/7a13d3535b
2025-09-15[ruby/prism] Fix character literal forced encodingKevin Newton
If a character literal was followed by a string concatenation, then the forced encoding of the string concatenation could accidentally overwrite the explicit encoding of the character literal. We now handle this properly. https://github.com/ruby/prism/commit/125c375d74
2025-09-13[ruby/prism] Revert "Merge pull request #3606 from tenderlove/clear-flags"Takashi Kokubun
This reverts commit https://github.com/ruby/prism/commit/4052d93cf852, reversing changes made to https://github.com/ruby/prism/commit/47143d17b3f7. https://github.com/ruby/prism/commit/f117ec6354