From 7a288df7b85d3565f369b305f225c2cd5baa5905 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Tue, 11 Feb 2020 11:56:34 -0800 Subject: 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. --- spec/ruby/language/class_spec.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'spec/ruby/language') diff --git a/spec/ruby/language/class_spec.rb b/spec/ruby/language/class_spec.rb index 88b7a6a74f..2b9a4afef7 100644 --- a/spec/ruby/language/class_spec.rb +++ b/spec/ruby/language/class_spec.rb @@ -285,7 +285,7 @@ describe "A class definition extending an object (sclass)" do }.should raise_error(TypeError) end - ruby_version_is ""..."3.0" do + ruby_version_is ""..."2.8" do it "allows accessing the block of the original scope" do suppress_warning do ClassSpecs.sclass_with_block { 123 }.should == 123 @@ -293,6 +293,14 @@ describe "A class definition extending an object (sclass)" do end end + ruby_version_is "2.8" do + it "does not allow accessing the block of the original scope" do + -> { + ClassSpecs.sclass_with_block { 123 } + }.should raise_error(SyntaxError) + end + end + it "can use return to cause the enclosing method to return" do ClassSpecs.sclass_with_return.should == :inner end -- cgit v1.2.3