Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn it #9152

Merged
merged 1 commit into from Dec 7, 2023
Merged

Warn it #9152

merged 1 commit into from Dec 7, 2023

Conversation

k0kubun
Copy link
Member

@k0kubun k0kubun commented Dec 7, 2023

@k0kubun k0kubun marked this pull request as ready for review December 7, 2023 07:09
@k0kubun k0kubun enabled auto-merge (squash) December 7, 2023 07:09
@k0kubun k0kubun merged commit ae76c8a into ruby:master Dec 7, 2023
99 of 100 checks passed
@k0kubun k0kubun deleted the warn-it branch December 7, 2023 07:15
koic added a commit to koic/rubocop that referenced this pull request Dec 7, 2023
Follow up https://bugs.ruby-lang.org/issues/18980 and ruby/ruby#9152.

Emulates the following Ruby warnings in Ruby 3.3.

```ruby
$ ruby -e '0.times { it }'
-e:1: warning: `it` calls without arguments will refer to the first block param in Ruby 3.4;
use it() or self.it
```

`it` calls without arguments will refer to the first block param in Ruby 3.4.
So use `it()` or `self.it` to ensure compatibility.

```ruby
# bad
do_something { it }

# good
do_something { it() }
do_something { self.it }
```
bbatsov pushed a commit to rubocop/rubocop that referenced this pull request Dec 9, 2023
Follow up https://bugs.ruby-lang.org/issues/18980 and ruby/ruby#9152.

Emulates the following Ruby warnings in Ruby 3.3.

```ruby
$ ruby -e '0.times { it }'
-e:1: warning: `it` calls without arguments will refer to the first block param in Ruby 3.4;
use it() or self.it
```

`it` calls without arguments will refer to the first block param in Ruby 3.4.
So use `it()` or `self.it` to ensure compatibility.

```ruby
# bad
do_something { it }

# good
do_something { it() }
do_something { self.it }
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant