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

84968 Коммитов

Автор SHA1 Сообщение Дата
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
Mari Imaizumi 339128b190 [ruby/reline] Refactored Default Key Bindings
(https://github.com/ruby/reline/pull/678)

* Reduce duplicate method

* Configured default key mapping with Readline when the method exists

* Remove undefined methods

https://github.com/ruby/reline/commit/155f7047bb
2024-04-14 17:33:51 +00:00
tomoya ishida 1648c4436e [ruby/reline] Refactor waiting_proc and waiting_operator_proc
(https://github.com/ruby/reline/pull/649)

* Fix waiting_proc precedence

* Fix waiting_operator bugs

* Add waiting_proc and vi_waiting_operator test

* Fix vi waiting operator arg number

vi_arg and vi_waiting_operator_arg should be multiplied

* Implement `yy` copies whole line in vi_command mode

* Simplify incremental search cancel test

* Add complex vi test with waiting_proc and vi_waiting_operator, split test input

https://github.com/ruby/reline/commit/777dffae1c
2024-04-14 14:28:15 +00:00
Nobuyoshi Nakada 8d5d6ec6e7
[pty] Fix missing `or` 2024-04-14 20:35:34 +09:00
Nobuyoshi Nakada 3368913be3 [pty] Fix `ptsname_r` fallback
If `posix_openpt` is available, also `ptsname` should be available.
2024-04-14 20:27:05 +09:00
Stan Lo 04ba96e619 [ruby/irb] Allow defining custom commands in IRB
(https://github.com/ruby/irb/pull/886)

This is a feature that has been requested for a long time. It is now
possible to define custom commands in IRB.

Example usage:

```ruby
require "irb/command"

class HelloCommand < IRB::Command::Base
  description "Prints hello world"
  category "My commands"
  help_message "It doesn't do more than printing hello world."

  def execute
    puts "Hello world"
  end
end

IRB::Command.register(:hello, HelloCommand)
```

https://github.com/ruby/irb/commit/888643467c
2024-04-14 11:01:43 +00:00
Michael J. Giarlo 76b10f2ee1 [ruby/reline] Support `menu-complete-backward` command for upward
navigation
(https://github.com/ruby/reline/pull/677)

Fixes https://github.com/ruby/reline/pull/675

This commit extracts the upward navigation condition in `LineEditor#input_key` to a new private method, and adds a new alias. This change allows Reline to support upward navigation in when a user has configured `inputrc` to map Shift-Tab to `menu-complete-backward`, a common setting in Bash (>= 4.x).

Instead of special-casing upward navigation in `LineEditor#input_key`, we now allow it to be processed by the branch that calls `process_key`. The extracted method no longer includes the editing mode check since this check is already made by `#wrap_method_call` by the time `#completion_journey_up` (or `#menu_complete_backward`) is called. Since upward navigation is happening in a method other than `#input_key` now, the `completion_occurs` variable that used to be local to `#input_key` is changed to an instance variable so that the new method can change its value. (I see many examples of mutating such instance variables in `LineEditor`, so I assumed this would be an uncontroversial change consistent with the coding practices already in place.)

Test coverage of this change has been added to the emacs and vi `KeyActor` tests.

Many thanks to @ima1zumi for their very helpful comments on #675 which encouraged me to contribute this work!

https://github.com/ruby/reline/commit/2ccdb374a4
2024-04-14 09:13:20 +00:00
yui-knk 38b8bdb8ea Remove undefined function's prototype declaration
89cfc15207 removed the definition of these functions.
2024-04-14 10:51:16 +09:00
yui-knk 924b928e35 Remove unused functions from `struct rb_parser_config_struct` 2024-04-14 09:08:19 +09:00
yui-knk 5970386a2e Use `rb_parser_string_t *` for `delayed.token` 2024-04-14 09:08:19 +09:00
Zack Deveau c479492a67 Resize ary when `Array#sort!` block modifies embedded ary
In cases where `rb_ary_sort_bang` is called with a block and
tmp is an embedded array, we need to account for the block
potentially impacting the capacity of ary.

ex:
```
var_0 = (1..70).to_a
var_0.sort! do |var_0_block_129, var_1_block_129|
  var_0.pop
  var_1_block_129 <=> var_0_block_129
end.shift(3)
```

The above example can put the array into a corrupted state
resulting in a heap buffer overflow and possible segfault:
```
ERROR: AddressSanitizer: heap-buffer-overflow on address [...]
WRITE of size 560 at 0x60b0000034f0 thread T0 [...]
```

This commit adds a conditional to determine when the capacity
of ary has been modified by the provided block. If this is
the case, ensure that the capacity of ary is adjusted to
handle at minimum the len of tmp.
2024-04-14 08:41:47 +09:00
Kevin Newton 43a6690d21
[PRISM] Enable passing test_parenthesised_statement_argument 2024-04-12 19:47:04 -04:00
Kevin Newton 3c0756752c [ruby/prism] Better error message on statement inside argument list
https://github.com/ruby/prism/commit/3b1a99526a
2024-04-12 21:46:42 +00:00
Kevin Newton 10d0abb437 [PRISM] Enable passing tests from latest prism 2024-04-12 17:46:31 -04:00
Kevin Newton 7baecc2e36 [PRISM] Emit parse warnings before raising syntax errors 2024-04-12 17:46:31 -04:00
Kevin Newton 650b5e5aa2 [PRISM] Enable more passing tests 2024-04-12 17:46:31 -04:00
Kevin Newton 1521af3259 [ruby/prism] Better error message on invalid def
https://github.com/ruby/prism/commit/d398e7d22c
2024-04-12 17:49:17 +00:00
Kevin Newton 52b862398d [ruby/prism] Syntax error for block argument on yield
https://github.com/ruby/prism/commit/9feeafbc67
2024-04-12 17:30:37 +00:00
Kevin Newton 0424c1fa7b [ruby/prism] Fix up embdoc lexing on EOF
https://github.com/ruby/prism/commit/8ee43be26d
2024-04-12 16:50:34 +00:00
Peter Zhu 9bab179ca3 Don't treat flonum specially in object ID
flonum is just a special constant, so we don't need to treat it in any
special way.
2024-04-12 11:27:08 -04:00
Peter Zhu edec690e03 Refactor how object IDs work for special consts
We don't need to treat static symbols in any special way since they
can't be confused with other special consts or GC managed objects.
2024-04-12 11:27:08 -04:00
Kevin Newton 3629d4df66 [PRISM] Enable passing tests for prism 2024-04-12 11:07:04 -04:00
Kevin Newton c41ecf3f47 [ruby/prism] Create the warning for unreachable statements
https://github.com/ruby/prism/commit/e17c86b886
2024-04-12 14:58:03 +00:00
Kevin Newton c553d34835 [ruby/prism] Warn void regardless of eval
https://github.com/ruby/prism/commit/48ba434fa4
2024-04-12 14:30:57 +00:00
Kevin Newton 5f2bcbb6d4
[PRISM] Ensure no void warnings in rubyoptions test 2024-04-12 10:29:39 -04:00
Kevin Newton 8e514bedf9 [ruby/prism] Remove outdated comment
https://github.com/ruby/prism/commit/9adc88ddf8
2024-04-12 14:10:21 +00:00
Kevin Newton 4fc457e2b7 [ruby/prism] Implement the void statement warning
https://github.com/ruby/prism/commit/802ff71cd4
2024-04-12 14:10:20 +00:00
Stan Lo 0924ff2d39 [ruby/prism] Fix parser translation's heredoc whitespace calculation
Given this example:

```rb
<<~HEREDOC
  #{x}
HEREDOC
```

Both the parser gem and Prism's translation layer would generate the following AST:

```
s(:dstr,
  s(:begin,
    s(:int, 1)),
  s(:str, " a\n"))
```

However, the parser gem inserts a empty string node into this node's location, like:

```
<Parser::Source::Map::Heredoc:0x0000000104ce73b8
 @expression=#<Parser::Source::Range (string) 0...10>,
 @heredoc_body=#<Parser::Source::Range (string) 11...20>,
 @heredoc_end=#<Parser::Source::Range (string) 20...27>,
 @node=s(:dstr,
  s(:str, ""),
  s(:begin,
    s(:int, 1)),
  s(:str, " a\n"))>
```

This is required to calculate the correct whitespace for the heredoc body.

We need to adjust the translation layer to account for this.

With this fix, we also won't need to ignore the tilde heredoc fixture anymore.

https://github.com/ruby/prism/commit/e7372e3ba5
2024-04-12 13:55:35 +00:00
Kevin Newton abd05c848f
Sync latest prism 2024-04-12 09:52:29 -04:00
David Marshall a64a42ae38 [rubygems/rubygems] `bundle add --glob` continued- quote glob value invocation in specs, add banner text for CLI recommending single quotes
https://github.com/rubygems/rubygems/commit/6d2cf955f9
2024-04-12 13:31:43 +00:00
David Marshall c4b5f3f142 [rubygems/rubygems] bundler CLI option for add gem --glob=
Bundler online documentation says that if the gem is located within a subdirectory of a git repository,
you can use the `:glob` option to specify the location of its .gemspec

`gem 'cf-copilot', git: 'https://github.com/cloudfoundry/copilot', glob: 'sdk/ruby/*.gemspec'`

This change allows for equivalent functionality from the bundler CLI

`bundle add cf-copilot --git=https://github.com/cloudfoundry/copilot --glob=sdk/ruby/*.gemspec`

https://github.com/rubygems/rubygems/commit/91052e5868
2024-04-12 13:31:43 +00:00
Stan Lo f1d9e895b9 [ruby/irb] Pass statements to Context#evaluate
(https://github.com/ruby/irb/pull/920)

This has a few benefits:

- We can keep hiding the evaluation logic inside the Context level, which
  has always been the convention until #824 was merged recently.
- Although not an official API, gems like `debug` and `mission_control-jobs`
  patch `Context#evaluate` to wrap their own logic around it. This implicit
  contract was broken after #824, and this change restores it.

In addition to the refactor, I also converted some context-level evaluation
tests into integration tests, which are more robust and easier to maintain.

https://github.com/ruby/irb/commit/b32aee4068
2024-04-12 12:01:03 +00:00
Satoshi Tagomori 7b8b936f4a
[DOC] Fix the wrong comment
This function checks the CL's superclasses containing the class C at
the end of it. That means C is a superclass of CL, not a subclass.
2024-04-12 18:31:22 +09:00
Nobuyoshi Nakada 91c457e091
Parenthesized SVN IDs in .mailmap look too verbose [ci skip] 2024-04-12 18:22:04 +09:00
Nobuyoshi Nakada 69823b97b5
[Bug #20423] Fix error message of prism 2024-04-12 17:02:46 +09:00
Nobuyoshi Nakada e36988450e
[Bug #20423] Disallow anonymous block within argument forwarding 2024-04-12 16:07:49 +09:00
Takashi Kokubun 971b552735 [PRISM] Suppress compiler warnings
../prism_compile.c: In function ‘pm_compile_node’:
../compile.c:583:24: warning: ‘retry_end_l’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  583 |     anchor->last->next = elem;
      |     ~~~~~~~~~~~~~~~~~~~^~~~~~
In file included from ../compile.c:14256:
../prism_compile.c:5796:16: note: ‘retry_end_l’ was declared here
 5796 |         LABEL *retry_end_l;
      |                ^~~~~~~~~~~
../compile.c:255:42: warning: ‘retry_label’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  255 | #define LABEL_REF(label) ((label)->refcnt++)
      |                                          ^~
In file included from ../compile.c:14256:
../prism_compile.c:5795:16: note: ‘retry_label’ was declared here
 5795 |         LABEL *retry_label;
      |                ^~~~~~~~~~~
../prism_compile.c:5919:52: warning: ‘previous_block’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 5919 |             ISEQ_COMPILE_DATA(iseq)->current_block = previous_block;
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
2024-04-11 17:31:28 -07:00
Kevin Newton 842f151d79 [PRISM] Enable more passing tests 2024-04-11 15:47:30 -04:00
Cody Cutrer c5e661b1d7 [rubygems/rubygems] Fix installing plugins via relative paths
This affected both CLI and Gemfile installs

https://github.com/rubygems/rubygems/commit/a0d101a8df
2024-04-11 19:35:28 +00:00
Kevin Newton cd516ebd20 [ruby/prism] Add Location#chop
https://github.com/ruby/prism/commit/5dd57f4b84
2024-04-11 18:53:30 +00:00
Kevin Newton 58f93eec18 [PRISM] Fix break in super block 2024-04-11 14:39:04 -04:00
Kevin Newton bb5ed8b3df [PRISM] Fix flags on local variable operator write nodes 2024-04-11 12:18:51 -04:00
Peter Zhu f2369de2a4 Remove redundant cast
ptr is already of the VALUE type, so we don't need to cast it.
2024-04-11 12:08:03 -04:00
Nobuyoshi Nakada ca81f5a5de
Realclean extracted bundled gems and lock files 2024-04-11 23:47:32 +09:00
Nobuyoshi Nakada 2df4638538
Cleanings of .bundle do not need cleanings of ext 2024-04-11 23:47:32 +09:00
Alan Wu c2622b5253
YJIT: x64: Remove register shuffle with `opt_and` and friends (#10498)
This is best understood by looking at the change to the output:

```diff
  # Insn: 0002 opt_and (stack_size: 2)
  - mov rax, rsi
  - and rax, rdi
  - mov rsi, rax
  + and rsi, rdi
```

It's a bit awkward to match against due to how stack operands are
lowered, but hey, it's nice to save the 2 unnecessary MOVs.
2024-04-11 10:37:56 -04:00
Jean Boussier db0cf1aef9 prism_compile.c: use rb_enc_interned_str to reduce allocations
The `rb_fstring(rb_enc_str_new())` pattern is inefficient because:

- It passes a mutable string to `rb_fstring` so if it has to be interned it will first be duped.
- It an equivalent interned string already exists, we allocated the string for nothing.

With `rb_enc_interned_str` we either directly get the pre-existing string with 0 allocations,
or efficiently directly intern the one we create without first duping it.
2024-04-11 14:48:30 +02:00
Kevin Newton 56f9ac8d31 [ruby/prism] More unreachables
https://github.com/ruby/prism/commit/735f3122c2
2024-04-11 12:12:34 +00:00
Jean Boussier 9183101aa7 prism_compile.c: X_STRING should be frozen
The backtick method recieves a frozen string unless it is interpolated.

Otherwise the string held in the ISeq could be mutated by a custom
backtick method.
2024-04-11 08:08:30 -04:00
Naoto Ono b2f8de3d9d Launchable: Correctly configure the missing "os" flavor in ubuntu.yaml 2024-04-11 20:25:08 +09:00