ruby-changes:62843
From: nagachika <ko1@a...>
Date: Sun, 6 Sep 2020 10:55:12 +0900 (JST)
Subject: [ruby-changes:62843] e778de2c82 (ruby_2_7): merge revision(s) 11963da9e8e98821860fbb0c0f2adc118860c814: [Backport #16603] [Backport #17141]
https://git.ruby-lang.org/ruby.git/commit/?id=e778de2c82 From e778de2c82478dda930cfc8d795ed4e0e60ea775 Mon Sep 17 00:00:00 2001 From: nagachika <nagachika@r...> Date: Sun, 6 Sep 2020 10:54:53 +0900 Subject: merge revision(s) 11963da9e8e98821860fbb0c0f2adc118860c814: [Backport #16603] [Backport #17141] Check type of empty keyword [Bug #16603] Co-authored-by: Yusuke Endoh <mame@r...> diff --git a/compile.c b/compile.c index 15b7076..5f86a5b 100644 --- a/compile.c +++ b/compile.c @@ -4241,7 +4241,7 @@ compile_hash(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int popp https://github.com/ruby/ruby/blob/trunk/compile.c#L4241 FLUSH_CHUNK(); const NODE *kw = node->nd_next->nd_head; - int empty_kw = nd_type(kw) == NODE_LIT; /* foo( ..., **{}, ...) */ + int empty_kw = nd_type(kw) == NODE_LIT && RB_TYPE_P(kw->nd_lit, T_HASH); /* foo( ..., **{}, ...) */ int first_kw = first_chunk && stack_len == 0; /* foo(1,2,3, **kw, ...) */ int last_kw = !node->nd_next->nd_next; /* foo( ..., **kw) */ int only_kw = last_kw && first_kw; /* foo(1,2,3, **kw) */ diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index a045955..e9be530 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -5052,6 +5052,12 @@ class TestKeywordArgumentsSymProcRefinements < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L5052 end end + def test_splat_fixnum + bug16603 = '[ruby-core:97047] [Bug #16603]' + assert_raise(TypeError, bug16603) { p(**42) } + assert_raise(TypeError, bug16603) { p(k:1, **42) } + end + def test_ruby2_keywords_hash_empty_kw_splat def self.foo(*a) a.last end singleton_class.send(:ruby2_keywords, :foo) diff --git a/version.h b/version.h index def4cde..de0ba11 100644 --- a/version.h +++ b/version.h @@ -2,11 +2,11 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L2 # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 1 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 119 +#define RUBY_PATCHLEVEL 120 #define RUBY_RELEASE_YEAR 2020 #define RUBY_RELEASE_MONTH 9 -#define RUBY_RELEASE_DAY 5 +#define RUBY_RELEASE_DAY 6 #include "ruby/version.h" -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/