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:
parent
ea32715e00
commit
7a288df7b8
Notes:
git
2020-02-12 05:44:46 +09:00
5 changed files with 29 additions and 21 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue