Issue #20342 has been updated by nobu (Nobuyoshi Nakada).
https://github.com/ruby/ruby/pull/10271
I'm not sure these methods should print the warning too.
----------------------------------------
Bug #20342: Top level `public`, `private` and `ruby2_keywords` do not work in wrapped
load
https://bugs.ruby-lang.org/issues/20342#change-107289
* Author: nobu (Nobuyoshi Nakada)
* Status: Open
* Backport: 3.0: REQUIRED, 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED
----------------------------------------
With this file:
```ruby
# load.rb
public def f = :ok
```
It is OK when `require`d.
```sh-session
$ ruby -r ./load.rb -e 'p f'
:ok
```
Simple `load` is OK too.
```sh-session
$ ruby -e 'load ARGV[0]; p f' load.rb
:ok
```
Wrapped `load` fails.
```sh-session
$ ruby -e 'load ARGV[0], true' load.rb
load.rb:1:in 'public': undefined method 'f' for class 'Object'
(NameError)
public def f = :ok
^^^^^^
from load.rb:1:in '<top (required)>'
from -e:1:in 'Kernel#load'
from -e:1:in '<main>'
```
--
https://bugs.ruby-lang.org/