ruby-changes:47962
From: nobu <ko1@a...>
Date: Sat, 30 Sep 2017 21:26:30 +0900 (JST)
Subject: [ruby-changes:47962] nobu:r60077 (trunk): eval.c: check type
nobu 2017-09-30 21:26:23 +0900 (Sat, 30 Sep 2017) New Revision: 60077 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60077 Log: eval.c: check type * eval.c (ignored_block): check argument type, which must be Module. [ruby-dev:50270] [Bug #13956] Modified files: trunk/eval.c trunk/test/ruby/test_refinement.rb Index: test/ruby/test_refinement.rb =================================================================== --- test/ruby/test_refinement.rb (revision 60076) +++ test/ruby/test_refinement.rb (revision 60077) @@ -1961,6 +1961,27 @@ class TestRefinement < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/ruby/test_refinement.rb#L1961 end end + def test_using_wrong_argument + bug = '[ruby-dev:50270] [Bug #13956]' + pattern = /expected Module/ + assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}") + bug = ""#{bug.dump} + pattern = /#{pattern}/ + begin; + assert_raise_with_message(TypeError, pattern, bug) { + using(1) do end + } + end; + assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}") + bug = ""#{bug.dump} + pattern = /#{pattern}/ + begin; + assert_raise_with_message(TypeError, pattern, bug) { + Module.new {using(1) {}} + } + end; + end + class ToString c = self using Module.new {refine(c) {def to_s; "ok"; end}} Index: eval.c =================================================================== --- eval.c (revision 60076) +++ eval.c (revision 60077) @@ -1482,6 +1482,7 @@ static void https://github.com/ruby/ruby/blob/trunk/eval.c#L1482 ignored_block(VALUE module, const char *klass) { const char *anon = ""; + Check_Type(module, T_MODULE); if (!RTEST(rb_search_class_path(module))) { anon = ", maybe for Module.new"; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/