summaryrefslogtreecommitdiff
path: root/test/ripper
AgeCommit message (Collapse)Author
2025-02-13merge revision(s) fb18bb183c24ca82b8f114ed090d62bd69b5df84: [Backport #20989]Takashi Kokubun
[Bug #20989] Ripper: Pass `compile_error` For the universal parser, `rb_parser_reg_fragment_check` function is shared between the parser and ripper. However `parser_params` struct is partially different, and `compile_error` function depends on that part indirectly.
2024-12-19[Bug #20969] Pass `assignable` from ripperNobuyoshi Nakada
For the universal parser, `rb_reg_named_capture_assign_iter_impl` function is shared between the parser and ripper. However `parser_params` struct is partially different, and `assignable` function depends on that part indirectly. Notes: Merged: https://github.com/ruby/ruby/pull/12400
2024-10-05[Bug #20784] Fix incomplete character syntax followed by EOFtompng
Notes: Merged: https://github.com/ruby/ruby/pull/11805
2024-08-07Fix leak of token_info when Ripper#warn jumpsPeter Zhu
For example, the following code leaks: class MyRipper < Ripper def initialize(src, &blk) super(src) @blk = blk end def warn(msg, *args) = @blk.call(msg) end $VERBOSE = true def call_parse = MyRipper.new("if true\n end\n") { |msg| return msg }.parse 10.times do 500_000.times do call_parse end puts `ps -o rss= -p #{$$}` end Before: 37536 53744 70064 86448 102576 119120 135248 151216 167744 183824 After: 19280 19696 19728 20336 20448 21408 21616 21616 21824 21840 Notes: Merged: https://github.com/ruby/ruby/pull/11289
2024-08-06Fix leak in warning of duplicate keys when Ripper#warn jumpsPeter Zhu
For example, the following code leaks: class MyRipper < Ripper def initialize(src, &blk) super(src) @blk = blk end def warn(msg, *args) = @blk.call(msg) end $VERBOSE = true def call_parse = MyRipper.new("if true\n end\n") { |msg| return msg }.parse 10.times do 500_000.times do call_parse end puts `ps -o rss= -p #{$$}` end Before: 34832 51952 69760 88048 105344 123040 141152 159152 176656 194272 After: 18400 20256 20272 20272 20272 20304 20368 20368 20368 20400 Notes: Merged: https://github.com/ruby/ruby/pull/11288
2024-07-31Fix leak of AST when Ripper#compile_error jumpsPeter Zhu
For example, the following script leaks: class MyRipper < Ripper def initialize(src, &blk) super(src) @blk = blk end def compile_error(msg) = @blk.call(msg) end def call_parse = MyRipper.new("/") { |msg| return msg }.parse 10.times do 100_000.times do call_parse end puts `ps -o rss= -p #{$$}` end Before: 93952 169040 244224 318784 394432 468224 544048 618560 693776 768384 After: 19776 19776 20352 20880 20912 21408 21328 21152 21472 20944 Notes: Merged: https://github.com/ruby/ruby/pull/11287
2024-07-24[Bug #20649] Allow `nil` as 2nd argument of `assign_error`Nobuyoshi Nakada
Fallback to the last token element in that case, for the backward compatibilities. Notes: Merged: https://github.com/ruby/ruby/pull/11235
2024-06-14[Bug #20579] ripper: Dispatch spaces at END-OF-INPUT without newlineNobuyoshi Nakada
2024-06-14[Bug #20578] ripper: Fix dispatching part at invalid escapesNobuyoshi Nakada
2024-06-07ripper: Fix excess `compile_error` at simple backref op_asgnNobuyoshi Nakada
Fix up 89cfc1520717257073012ec07105c551e4b8af7c.
2024-06-06[Bug #20521] ripper: Clean up strtermNobuyoshi Nakada
2024-06-01[Bug #20517] Make a multibyte character one token at meta escapeNobuyoshi Nakada
2024-05-24Update duplicated when clause warning messageKevin Newton
2024-05-12ripper: Fix opassign when assignment to backref variablesNobuyoshi Nakada
2024-05-12ripper: Use `$&` instead of quoting charaters in testsNobuyoshi Nakada
2024-05-11Fix SEGV when ripper hits `backref_error` on `command_asgn` or `arg`yui-knk
2024-05-01Fix memory leak in Ripper.sexpPeter Zhu
rb_ast_dispose does not free the rb_ast_t causing it to be leaked. This commit changes it to use rb_ast_free instead. For example: require "ripper" 10.times do 100_000.times do Ripper.sexp("") end puts `ps -o rss= -p #{$$}` end Before: 27648 32512 37376 42240 47232 52224 57344 62208 67072 71936 After: 22784 22784 22784 22784 22912 22912 22912 22912 22912 22912
2024-04-15Emit `warn` event for duplicated hash keys on ripperyui-knk
Need to use `rb_warn` macro instead of calling `rb_compile_warn` directly to emit `warn` event on ripper.
2024-04-11Fix segv when parsing `command` by ripperyui-knk
89cfc152071 made this event dispatch to pass `Qundef` to user defined callback method by mistake. This commit fix it to be `nil`.
2024-04-07Fix ripper to dispatch warning event for duplicated when clauseyui-knk
Need to separate `check_literal_when` function for parser and ripper otherwise warning event is not dispatched because parser `rb_warning1` is used in ripper.
2024-02-20[Feature #20257] Rearchitect Ripperyui-knk
Introduce another semantic value stack for Ripper so that Ripper can manage both Node and Ruby Object separately. This rearchitectutre of Ripper solves these issues. Therefore adding test cases for them. * [Bug 10436] https://bugs.ruby-lang.org/issues/10436 * [Bug 18988] https://bugs.ruby-lang.org/issues/18988 * [Bug 20055] https://bugs.ruby-lang.org/issues/20055 Checked the differences of `Ripper.sexp` for files under `/test/ruby` are only on test_pattern_matching.rb. The differences comes from the differences between `new_hash_pattern_tail` functions between parser and Ripper. Ripper `new_hash_pattern_tail` didn’t call `assignable` then `kw_rest_arg` wasn’t marked as local variable. This is also fixed by this commit. ``` --- a/./tmp/before/test_pattern_matching.rb +++ b/./tmp/after/test_pattern_matching.rb @@ -3607,7 +3607,7 @@ [:in, [:hshptn, nil, [], [:var_field, [:@ident, “a”, [984, 13]]]], [[:binary, - [:vcall, [:@ident, “a”, [985, 10]]], + [:var_ref, [:@ident, “a”, [985, 10]]], :==, [:hash, nil]]], nil]]], @@ -3662,7 +3662,7 @@ [:in, [:hshptn, nil, [], [:var_field, [:@ident, “a”, [993, 13]]]], [[:binary, - [:vcall, [:@ident, “a”, [994, 10]]], + [:var_ref, [:@ident, “a”, [994, 10]]], :==, [:hash, [:assoclist_from_args, @@ -3813,7 +3813,7 @@ [:command, [:@ident, “raise”, [1022, 10]], [:args_add_block, - [[:vcall, [:@ident, “b”, [1022, 16]]]], + [[:var_ref, [:@ident, “b”, [1022, 16]]]], false]]], [:else, [[:var_ref, [:@kw, “true”, [1024, 10]]]]]]]], nil, @@ -3876,7 +3876,7 @@ [:@int, “0”, [1033, 15]]], :“&&“, [:binary, - [:vcall, [:@ident, “b”, [1033, 20]]], + [:var_ref, [:@ident, “b”, [1033, 20]]], :==, [:hash, nil]]]], nil]]], @@ -3946,7 +3946,7 @@ [:@int, “0”, [1042, 15]]], :“&&“, [:binary, - [:vcall, [:@ident, “b”, [1042, 20]]], + [:var_ref, [:@ident, “b”, [1042, 20]]], :==, [:hash, [:assoclist_from_args, @@ -5206,7 +5206,7 @@ [[:assoc_new, [:@label, “c:“, [1352, 22]], [:@int, “0”, [1352, 25]]]]]], - [:vcall, [:@ident, “r”, [1352, 29]]]], + [:var_ref, [:@ident, “r”, [1352, 29]]]], false]]], [:binary, [:call, @@ -5299,7 +5299,7 @@ [:assoc_new, [:@label, “c:“, [1367, 34]], [:@int, “0”, [1367, 37]]]]]], - [:vcall, [:@ident, “r”, [1367, 41]]]], + [:var_ref, [:@ident, “r”, [1367, 41]]]], false]]], [:binary, [:call, @@ -5931,7 +5931,7 @@ [:in, [:hshptn, nil, [], [:var_field, [:@ident, “r”, [1533, 11]]]], [[:binary, - [:vcall, [:@ident, “r”, [1534, 8]]], + [:var_ref, [:@ident, “r”, [1534, 8]]], :==, [:hash, [:assoclist_from_args, ```
2024-02-15Do not include a backtick in error messages and backtracesYusuke Endoh
[Feature #16495]
2023-12-02[Bug #19838] Flush delayed token nonconsecutive with the next tokenNobuyoshi Nakada
2023-12-01Dispatch invalid hex escape content tooNobuyoshi Nakada
2023-12-01[Bug #20030] dispatch invalid escaped character without ignoring itNobuyoshi Nakada
2023-11-02Added TestRipper namespace to test_call_colon2Hiroshi SHIBATA
2023-11-02test/ripper: nest helper classes under TestRipper modulelukeg
Generic names like Node and NodeList should be namespaced properly.
2023-08-26[Bug #19851] Ripper: Hide internal block argument IDNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/8293
2023-08-09Fix memory leak for incomplete lambdasPeter Zhu
[Bug #19836] The parser does not free the chain of `struct vtable`, which causes memory leaks. The following script reproduces this issue: ``` 10.times do 100_000.times do Ripper.parse("-> {") end puts `ps -o rss= -p #{$$}` end ``` Notes: Merged: https://github.com/ruby/ruby/pull/8192
2023-08-09Fix memory leak in parser for incomplete tokensPeter Zhu
[Bug #19835] The parser does not free the `tbl` of the `struct vtable` when there are leftover `lvtbl` in the parser. This causes a memory leak. The following script reproduces this issue: ``` 10.times do 100_000.times do Ripper.parse("class Foo") end puts `ps -o rss= -p #{$$}` end ``` Notes: Merged: https://github.com/ruby/ruby/pull/8192
2023-08-03Remove --disable-gems for assert_separatelyPeter Zhu
assert_separately adds --disable=gems so we don't need to add --disable-gems when calling assert_separately. Notes: Merged: https://github.com/ruby/ruby/pull/8162
2023-08-01[Bug #19788] Use the result of `tCOLON2` eventNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/8144
2023-07-16Fix null pointer access in Ripper#initializeNobuyoshi Nakada
In `rb_ruby_ripper_parser_allocate`, `r->p` is NULL between creating `self` and `parser_params` assignment. As GC can happen there, the typed-data functions for it need to consider the case. Notes: Merged: https://github.com/ruby/ruby/pull/8085
2023-06-28Increase memory leak test timeoutPeter Zhu
The test times out on some platforms, so increase the timeout. Notes: Merged: https://github.com/ruby/ruby/pull/7992
2023-06-28Fix memory leak in RipperPeter Zhu
The following script leaks memory in Ripper: ```ruby require "ripper" 20.times do 100_000.times do Ripper.parse("") end puts `ps -o rss= -p #{$$}` end ``` Notes: Merged: https://github.com/ruby/ruby/pull/7985
2023-06-20[Bug #19736] Recover after unterminated interpolationNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/7963
2023-04-07[Bug #19563] Yield words separators per linesNobuyoshi Nakada
So that newlines across a here-doc terminator will be separated tokens. Cf. https://github.com/ruby/irb/pull/558 Notes: Merged: https://github.com/ruby/ruby/pull/7675 Merged-By: nobu <nobu@ruby-lang.org>
2023-04-01`*` in an array pattern should not be parsed as nil in ripperKazuki Tsujimoto
After 6c0925ba7017efde6091e2ec4f1a6be268166696, it was impossible to distinguish between the presence or absence of `*`. # Before the commit Ripper.sexp('0 in []')[1][0][2][1] #=> [:aryptn, nil, nil, nil, nil] Ripper.sexp('0 in [*]')[1][0][2][1] #=> [:aryptn, nil, nil, [:var_field, nil], nil] # After the commit Ripper.sexp('0 in []')[1][0][2][1] #=> [:aryptn, nil, nil, nil, nil] Ripper.sexp('0 in [*]')[1][0][2][1] #=> [:aryptn, nil, nil, nil, nil] This commit reverts it.
2023-03-28Ripper: Add keyword options to `assert_parse_files`Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/7602
2023-03-26[Bug #19175] p_kw without a sub pattern should be `assignable'Kazuki Tsujimoto
2023-03-26[Bug #19175] p_rest should be `assignable'Kazuki Tsujimoto
It should also check for duplicate names.
2023-02-02[Bug #19399] Parsing invalid heredoc inside block parameterNobuyoshi Nakada
Although this is of course invalid as Ruby code, allow to just parse and tokenize. Notes: Merged: https://github.com/ruby/ruby/pull/7229
2023-01-02[Bug #19291] Rewind to the previous lineNobuyoshi Nakada
When rewinding looking ahead after newline token, also reset the last line string, the pointers to it, and the location, not only the line number. Notes: Merged: https://github.com/ruby/ruby/pull/7054
2023-01-02Adjut indent [ci skip]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/7054
2022-08-28[Bug #18963] Separate string contents by here document terminatorNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6292
2022-08-12[Bug #18962] Do not read again once reached EOFNobuyoshi Nakada
`Ripper::Lexer#parse` re-parses the source code with syntax errors when `raise_errors: false`. Co-Authored-By: tompng <tomoyapenguin@gmail.com> Notes: Merged: https://github.com/ruby/ruby/pull/6233
2022-06-14ripper: Check if anonymous parameters defined [Bug #18828]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6016
2021-12-14ripper: refine test to show expected statesNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5264
2021-09-11Hash values should be omitted in Ripper resultsShugo Maeda
2021-08-15Extract the wrapped value when yydebug [Bug #18075]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4742