From c79402c4f0e40a3ebebda9761e47ff1b3d12ed53 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 9 Jan 2016 09:26:23 +0000 Subject: [PATCH] symbol.h: unexpected safe call * symbol.h (is_attrset_id): ASET is an attrset ID. fix unexpected safe call instead of an ordinary ASET. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ symbol.h | 2 +- test/ruby/test_call.rb | 7 +++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 2e4fb69ed3..3b568d3f41 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Jan 9 18:25:57 2016 Nobuyoshi Nakada + + * symbol.h (is_attrset_id): ASET is an attrset ID. fix + unexpected safe call instead of an ordinary ASET. + Sat Jan 9 10:44:33 2016 Nobuyoshi Nakada * configure.in, win32/setup.mak: extract RUBY_PROGRAM_VERSION from diff --git a/symbol.h b/symbol.h index 7d95491ee6..641b9792ed 100644 --- a/symbol.h +++ b/symbol.h @@ -36,7 +36,7 @@ struct RSymbol { #define is_local_id(id) (id_type(id)==ID_LOCAL) #define is_global_id(id) (id_type(id)==ID_GLOBAL) #define is_instance_id(id) (id_type(id)==ID_INSTANCE) -#define is_attrset_id(id) (id_type(id)==ID_ATTRSET) +#define is_attrset_id(id) ((id)==idASET||id_type(id)==ID_ATTRSET) #define is_const_id(id) (id_type(id)==ID_CONST) #define is_class_id(id) (id_type(id)==ID_CLASS) #define is_junk_id(id) (id_type(id)==ID_JUNK) diff --git a/test/ruby/test_call.rb b/test/ruby/test_call.rb index 7ef8d06936..fb79eadb64 100644 --- a/test/ruby/test_call.rb +++ b/test/ruby/test_call.rb @@ -83,4 +83,11 @@ class TestCall < Test::Unit::TestCase def test_safe_call_block_call_command assert_nil(("a".sub! "b" do end&.foo 1 do end)) end + + def test_invalid_safe_call + h = nil + assert_raise(NoMethodError) { + h[:foo] = nil + } + end end