Issue #15575 has been updated by ko1 (Koichi Sasada).


Similar strange example (off-topic):

```
1.times{
  class C
    break
    def undefined_method; end
  end
  p :unrechable
}
p [:ok, C.instance_methods(false)] #=> [:ok, []]
```

We can break from `class` syntax.
I hope nobody use it :(

----------------------------------------
Feature #15575: Prohibit to pass a block singleton class
https://bugs.ruby-lang.org/issues/15575#change-76592

* Author: ko1 (Koichi Sasada)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
----------------------------------------
The following code works now:

```
def foo
  class << Object.new
    yield
  end
end

foo{ p :ok } #=> :ok
```

but I think this feature is very strange because local variables are not active in singleton class.

How about to prohibit this feature?

plan: warning at ruby 2.7 and prohibit it in ruby 3.




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>