[前][次][番号順一覧][スレッド一覧]

ruby-changes:52476

From: k0kubun <ko1@a...>
Date: Tue, 11 Sep 2018 23:10:09 +0900 (JST)
Subject: [ruby-changes:52476] k0kubun:r64685 (trunk): bare_instructions.rb: use Hash#fetch to read attr

k0kubun	2018-09-11 23:10:00 +0900 (Tue, 11 Sep 2018)

  New Revision: 64685

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64685

  Log:
    bare_instructions.rb: use Hash#fetch to read attr
    
    to raise descriptive KeyError instead of NoMethodError in case these
    attrs are accidentally removed.

  Modified files:
    trunk/tool/ruby_vm/models/bare_instructions.rb
Index: tool/ruby_vm/models/bare_instructions.rb
===================================================================
--- tool/ruby_vm/models/bare_instructions.rb	(revision 64684)
+++ tool/ruby_vm/models/bare_instructions.rb	(revision 64685)
@@ -102,11 +102,11 @@ class RubyVM::BareInstructions https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/models/bare_instructions.rb#L102
   end
 
   def handles_sp?
-    /\b(false|0)\b/ !~ @attrs['handles_sp'].expr.expr
+    /\b(false|0)\b/ !~ @attrs.fetch('handles_sp').expr.expr
   end
 
   def always_leaf?
-    @attrs['leaf'].expr.expr == 'true;'
+    @attrs.fetch('leaf').expr.expr == 'true;'
   end
 
   def complicated_return_values?

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]