1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Make yield in singleton class definitions in methods a SyntaxError

This behavior was deprecated in 2.7 and scheduled to be removed
in 3.0.

Calling yield in a class definition outside a method is now a
SyntaxError instead of a LocalJumpError, as well.
This commit is contained in:
Jeremy Evans 2020-02-11 11:56:34 -08:00
parent ea32715e00
commit 7a288df7b8
Notes: git 2020-02-12 05:44:46 +09:00
5 changed files with 29 additions and 21 deletions

View file

@ -296,14 +296,19 @@ assert_equal "true", %q{
s.return_eigenclass == class << s; self; end
}, '[ruby-core:21379]'
assert_equal "true", %q{
class Object
def yield_eigenclass
class << self
yield self
assert_match %r{Invalid yield}, %q{
STDERR.reopen(STDOUT)
begin
eval %q{
class Object
def yield_eigenclass
class << self
yield self
end
end
end
end
s = "foo"
s.yield_eigenclass {|c| c == class << s; self; end }
}, '[ruby-dev:40975]'
}
rescue SyntaxError => e
e.message
end
}