Граф коммитов

111 Коммитов

Автор SHA1 Сообщение Дата
Peter Zhu 584559d86a Fix leak of token_info when Ripper#warn jumps
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
2024-08-07 09:14:14 -04:00
Peter Zhu ced35800d4 Fix leak in warning of duplicate keys when Ripper#warn jumps
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
2024-08-06 10:19:50 -04:00
Peter Zhu 6358397490 Fix leak of AST when Ripper#compile_error jumps
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
2024-07-31 14:47:44 -04:00
Nobuyoshi Nakada 9e28354705
ripper: Fix excess `compile_error` at simple backref op_asgn
Fix up 89cfc15207.
2024-06-07 11:28:38 +09:00
Kevin Newton 47f0965269 Update duplicated when clause warning message 2024-05-24 12:36:54 -04:00
Nobuyoshi Nakada 5695c5df95
ripper: Fix opassign when assignment to backref variables 2024-05-12 15:38:22 +09:00
Nobuyoshi Nakada a1fb6cc978
ripper: Use `$&` instead of quoting charaters in tests 2024-05-12 15:36:42 +09:00
yui-knk 7e604a0263 Fix SEGV when ripper hits `backref_error` on `command_asgn` or `arg` 2024-05-11 20:47:15 +09:00
yui-knk 515e52a0b1 Emit `warn` event for duplicated hash keys on ripper
Need to use `rb_warn` macro instead of calling `rb_compile_warn`
directly to emit `warn` event on ripper.
2024-04-15 06:29:25 +09:00
yui-knk 7767db2379 Fix ripper to dispatch warning event for duplicated when clause
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-04-07 11:15:09 +09:00
Yusuke Endoh 25d74b9527 Do not include a backtick in error messages and backtraces
[Feature #16495]
2024-02-15 18:42:31 +09:00
Hiroshi SHIBATA 7149543f24
Added TestRipper namespace to test_call_colon2 2023-11-02 15:13:40 +09:00
lukeg 1925c6d555
test/ripper: nest helper classes under TestRipper module
Generic names like Node and NodeList should be namespaced properly.
2023-11-02 15:10:50 +09:00
Nobuyoshi Nakada 40efbc7e40 [Bug #19851] Ripper: Hide internal block argument ID 2023-08-26 02:08:53 +09:00
Nobuyoshi Nakada 382678d411 [Bug #19788] Use the result of `tCOLON2` event 2023-08-01 19:00:31 +09:00
Nobuyoshi Nakada 1a70973f75 ripper: Check if anonymous parameters defined [Bug #18828] 2022-06-14 20:41:41 +09:00
Nobuyoshi Nakada 50a534a152 ripper: wrap endless method in bodystmt [Bug #17869] 2021-05-21 18:28:24 +09:00
Nobuyoshi Nakada 050bb06e66 ripper: assertions for rescue/ensure in method body 2021-05-21 18:28:24 +09:00
Nobuyoshi Nakada 47328ad217
Ripper: Fixed erred token on wrong alias [Bug #17345] 2020-12-16 21:08:33 +09:00
Nobuyoshi Nakada 79b242260b
ripper: Invalid pragma value warning 2020-11-02 22:49:42 +09:00
Nobuyoshi Nakada 4ed0c33d13
Prohibit setter method names in all kinds of endless methods
Also unwrap NODE_RIPPER to check the method name.
2020-10-12 00:40:55 +09:00
Nobuyoshi Nakada 3d8705dcfd
Drop token info for endless method definition
Because it does not have closing `end`.
2020-06-25 01:14:26 +09:00
Nobuyoshi Nakada 419b0596a2
[ripper] added endless method definition event tests 2020-06-25 01:14:18 +09:00
Nobuyoshi Nakada 263b941321
[ripper] fix mismatched indentations warning [Bug #16981]
The scanner location has to be set from `lex.ptok` before it is
flushed by dispatching the scanner event.
2020-06-24 19:53:14 +09:00
Nobuyoshi Nakada 7f29e34f35
[ripper] fail unless got warning as expected 2020-06-24 19:52:39 +09:00
Kazuki Tsujimoto ddded1157a
Introduce find pattern [Feature #16828] 2020-06-14 09:24:36 +09:00
Jeremy Evans f8b4340fa2 Add leading arguments support to arguments forwarding
The idFWD_KWREST sections may be wrong. However, the existing
idFWD_KWREST sections for ... without leading arguments are already
broken.

Implements [Feature #16378]
2020-06-06 17:07:11 -07:00
Nobuyoshi Nakada 1c7f5a5712
Removed unnecessary RLIMIT_AS
Even without this limit, these assertions almost certainly cause a
NoMemoryError by removing the fix in 72ad8595f2.
2020-04-28 23:36:16 +09:00
Nobuyoshi Nakada fb6a489af2
Revert "Method reference operator"
This reverts commit 67c5747369.
[Feature #16275]
2019-11-12 17:24:48 +09:00
Nobuyoshi Nakada 62d4382877 Arguments forwarding [Feature #16253] 2019-10-22 02:35:43 +09:00
Nobuyoshi Nakada 33c5ad3154
Removed idNUMPARAM_0 2019-09-25 13:52:53 +09:00
Nobuyoshi Nakada ea68bb914a Changed numbered parameter prefix 2019-09-24 21:57:54 +09:00
Jeremy Evans 4d64693c70 Make ripper support **nil syntax
The on_params hook will use :nil as the keyword rest argument.
There is a new on_nokw_param hook as well.

This fixes a type issue in the previous code, where an ID was
passed where a VALUE was the declared type.  The symbol :nil is
passed instead of the id.
2019-08-30 12:39:31 -07:00
Koichi Sasada a9fd57056c double memory limit on MJIT.
On test with MJIT, sometimes it fails like:
http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/2189967
2019-08-09 13:04:56 +09:00
Nobuyoshi Nakada f19e048d24
Do not dispatch a nil token in ripper
As a comment token includes the newline, so delayed newline token
just follows it should not be dispatched.  [Bug #11485]

Co-Authored-By: Jeremy Evans <code@jeremyevans.net>
2019-07-04 15:58:47 +09:00
Nobuyoshi Nakada 3dba16a5d6
Test string content 2019-06-28 17:08:47 +09:00
Nobuyoshi Nakada 8d04f90da4
Fixed a variable name 2019-06-28 17:07:17 +09:00
Nobuyoshi Nakada 097554855c
Fix ripper fatal
* parse.y (parser_yylex): return END_OF_INPUT at unterminated here
  document instead of an error.  [Bug #15962]
2019-06-27 15:32:03 +09:00
Nobuyoshi Nakada 2a56702eee
Test for unterminated here-docs 2019-06-27 15:13:45 +09:00
ktsj 9738f96fcf Introduce pattern matching [EXPERIMENTAL]
[ruby-core:87945] [Feature #14912]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-17 06:48:03 +00:00
nobu afa1505ca8 parse.y: removed redundant number_arg parser event
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-19 06:23:36 +00:00
nobu fa66569afa parse.y: fix var_ref of numbered param in ripper
* parse.y (string_dvar, user_variable): register numbered
  parameter in ripper for var_ref.
  [ruby-core:91867] [Bug #15673]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-19 06:01:21 +00:00
nobu 12acc751e3 Numbered parameters [Feature #4475]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-17 05:21:18 +00:00
nobu 9800fc26b0 parse.y: no punctuation instance/class variables
* parse.y (parse_atmark): exclude punctuation follows @ marks,
  whereas it is inclusive after $ mark as some punctuation global
  variables exist.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67254 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-14 08:13:46 +00:00
nobu 67c5747369 Method reference operator
Introduce the new operator for method reference, `.:`.
[Feature #12125] [Feature #13581]
[EXPERIMENTAL]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-31 15:00:37 +00:00
mame c9d720b873 parse.y: remove "shadowing outer local variable" warning
You can now write the following without warning.

    user = User.all.find {|user| cond(user) }

Fixes [Feature #12490].
A patch from Soutaro Matsumoto <matsumoto@soutaro.com>.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-26 03:10:02 +00:00
mame b171d92046 Revert "parse.y: remove "shadowing outer local variable" warning"
I forgot to add the copyright of the patch...

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65368 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-26 03:08:10 +00:00
mame 7f69d4e41f parse.y: remove "shadowing outer local variable" warning
You can now write the following without warning.

  user = User.all.find {|user| cond(user) }

Fixes [Feature #12490].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65367 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-26 02:54:01 +00:00
normal 309042d8c1 test/ripper/test_parser_events.rb (test_block_variables): bump RLIMIT_AS again
I still seem to need more memory for parallel tests with MJIT...

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64381 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-15 18:56:34 +00:00
normal 1777e39c2a test/ripper/test_parser_events.rb (test_block_variables): increase RLIMIT_AS
Unfortunately, MJIT goes over the 100M RLIMIT_AS for this test
on x86-64 (Debian 9)

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-06 08:42:04 +00:00